This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Can anyone help me with Drag and Drop in swing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Can anyone help me with Drag and Drop in swing?" Watch "Can anyone help me with Drag and Drop in swing?" New topic
Author

Can anyone help me with Drag and Drop in swing?

Max Diaz
Greenhorn

Joined: Feb 19, 2010
Posts: 6
I'm trying to figure out how to enable drag and drop of JButtons between different JPanels. Basically I have a bunch of JButtons on screen whose only purpose is to display nice looking rectangles. I need to be able to drag any of the JButtons and drop them on a different JPanels. From what I gather about DnD in swing I need to set the transferhandler of the JPanels so they can accept JButtons dropped on them. According to the API the constructor for transferhandler accepts a Java Bean property. So you would pass in "text" to drag and drop text, but what do I pass in to drop a JButton?


Also what the hell is a Javabean?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

"Max MaxMax", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

JavaBean
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
The section from the Swing tutorial on Drag and Drop might help.
 
Don't get me started about those stupid light bulbs.
 
subject: Can anyone help me with Drag and Drop in swing?
 
Similar Threads
Transfer drop to sub-component (need help with)
Cannot get TransferHandler to work in Swing
Drag-&-Drop from MS Outlook to Java program
How to call a protected method in other packages non-subclass
Drag and Dropping within JTable