开发者

Select an image from JPanel

I am working on a small project which requires me to load images into a window and then move them around at will.

Thus far I can load images onto a JPanel simply by using a graphics object to draw them to the JPanel.

Now I'm faced with the challenge of figuring out how to differentiate between the various images I've loade开发者_运维问答d when I click on them so I can drag them around the screen.

Any ideas?


If you use a JLabel for each image, and make the JLabels subcomponents of the JPanel, it'll automatically draw the image, and you can add MouseListeners to each of them to be able to drag them around the screen.


Use the Component Mover to drag any component around the screen.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜