Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Can anyone help me with Drag and Drop in swing?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 67366
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Max MaxMax", please check your private messages for an important administrative matter.
 
Bear Bibeault
Marshal
Posts: 67366
173
Mac Mac OS X IntelliJ IDE jQuery Java
 
Rancher
Posts: 3140
27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The section from the Swing tutorial on Drag and Drop might help.
 
Skool. Stay in. Smartness. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!