Results 1 to 2 of 2
Thread: Drad and drop in JPanel
- 02-18-2011, 03:45 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 1
- Rep Power
- 0
Drad and drop in JPanel
Hello everyone,
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?
Thanks!
-
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.
Similar Threads
-
Placing a new JPanel over a paint overriden JPanel
By Tanshaydar in forum AWT / SwingReplies: 4Last Post: 12-08-2010, 06:00 PM -
Need to Save a data to file from JPanel and read the data back to Jpanel
By yashrajsen in forum AWT / SwingReplies: 1Last Post: 11-09-2010, 09:28 AM -
Drag and Drop JPanel at Runtime
By ravjot28 in forum AWT / SwingReplies: 3Last Post: 01-17-2010, 03:46 PM -
drag and drop - disable intra component drop
By tomba in forum AWT / SwingReplies: 4Last Post: 12-09-2009, 01:01 PM -
dynamically changing drop down box on selection in first drop down
By anjali in forum Advanced JavaReplies: 1Last Post: 04-01-2009, 10:28 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks