Results 1 to 2 of 2
Thread: Drad and drop in JPanel
- 02-18-2011, 04:45 PM #1Member
- Join Date
- Feb 2011
- Rep Power
Drad and drop in JPanel
I have a background image that is placed inside a JPanel. I would like to draw some objects over the background and to be able to drag and drop them. Currently I was able to achieve this effect by predefining the paint method of the JPanel. When I start dragging I check if the current mouse position is over an object and if so I redraw the object to the new coordinates and then draw the whole background again.
Is there a better way to do this? For example can I drag a JLabel with an icon and transparent background inside a JPanel? In general what would be the best technique to have this done?
Yes you can drag a JLabel easily over a JPanel doing what I think you want to do. JLayeredPane is useful in helping you do this.
- By Tanshaydar in forum AWT / SwingReplies: 4Last Post: 12-08-2010, 07:00 PM
- By yashrajsen in forum AWT / SwingReplies: 1Last Post: 11-09-2010, 10:28 AM
- By ravjot28 in forum AWT / SwingReplies: 3Last Post: 01-17-2010, 04:46 PM
- By tomba in forum AWT / SwingReplies: 4Last Post: 12-09-2009, 02:01 PM
- By anjali in forum Advanced JavaReplies: 1Last Post: 04-01-2009, 10:28 AM