Hello all.
I'm currrently working on a GUI that needs to support dragging some application-specific objects from a selection area onto a work area (JPanel). It's currently working in a "click where to place the object, then click the Add button" mode, but that's not good enough.
The obvious approach is to use D&D (Java 6 or later) with a custom DataFlavor for the objects, but I'm struggling to find and decent documentation or examples of how to fit the whole thing together. The Oracle tutorials do a decent job of listing all the classs and methods involved, but not how to fit it all into an application. There are many code samples on the web, but many are pre-Java6, and the remainder use Swing's built-in support for some specific data flavors.
If you have any experience of doing this, or know of any useful info source, I'd love to hear from you.
Thanks
James
ps: This is not homework ;)
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Recommended Answers
Jump to PostHmm I found this code somewhere on the net as a question on a forum (lost the link now), but I patched it up and altered it (still not the best) but hopefully it will give you the basic idea:
import …
Jump to PostSince you are using custom components, you will probably be needing to call
TransferHandler.exportAsDrag
yourself to get the drag started because JPanel has nosetDragEnabled
method. Instead, you will need to listen for mouse motion to detect the gesture that you want to begin the drag. I imagine you'll want …
All 7 Replies
DavidKroukamp
105
Master Poster
Team Colleague
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
bguild
163
Posting Whiz
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
DavidKroukamp
105
Master Poster
Team Colleague
Featured Poster
bguild
163
Posting Whiz
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.