The JavaTM Tutorial
Previous Page Trail Contents Next Page Start of Tutorial Search

Trail: Drag and Drop

One day we'll have a trail here. For now, here are some links to resources and examples:
How to drag and drop with Java 2 (article in JavaWorld - March 1999)
Has step-by-step directions on adding drag-and-drop support to a component (a subclass of JLabel). Has a list of resources, including links to the downloadable example, javadoc, 1.2 drag-and-drop bugs, ...

JavaBeans home page
Indirectly links to the Drag and Drop specification; might have other information related to Drag and Drop.

John Zukowski's example
From John: "Key points:
  • Drag from JTree, drop into JList.
  • Demonstrates using a custom data flavor for dragging the user data of the node
  • Can drop a file list into the JList."

Older example by John Zukowski
Here's John's description: "A D&D example I did back in July for beta 4. Probably needs a few updates for final (now that support is there for external Java dragging....) but a good start..."
Note: This example uses AWT components, not Swing components.

SwingDrop.java
A rough example showing plain-text drag-and-drop with a JTextArea. Prints diagnostics.
If you can recommend any other examples or resources, please send us mail with the subject drag and drop.

Previous Page Trail Contents Next Page Start of Tutorial Search

Casa de Bender