File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes DND out of an application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "DND out of an application?" Watch "DND out of an application?" New topic

DND out of an application?

Michael Remijan
Ranch Hand

Joined: May 29, 2002
Posts: 128

For the most part I've figured out DND with trees and other thing within a GUI but now I'd like to DND out of the application and say. Say I have a JTree representing directories on the file system. I'd like to be able to drag from my GUI onto the desktop and have windows copy the file to the desktop. Any ideas? Everytime I try it I get the "no drop" icon when I hover over the desktop.

Java EE Evangelist — Author, EJB 3 in Action 2nd Edition — Java Community Process Member
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
As shown in $1.5docs/guide/dragndrop/spec/dnd1.html#2.5.3 this

works okay (single files only) for copy_and_paste and for drag_n_drop from a JTree to the win xp desktop.
To test it I used a (plain) JTree with FileStore class nodes, a TransferHandler for the tree and a Transferable class like the one in TreeDrag from this thread DND from JTree to JTable. And copied the createMenuBar method from the DragPictureDemo2 app in the Adding Cut/Copy/Paste Support section of the DnD tutorial.
I agree. Here's the link:
subject: DND out of an application?
It's not a secret anymore!