File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Drag and Drop functionality in UI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Drag and Drop functionality in UI" Watch "Drag and Drop functionality in UI" New topic
Author

Drag and Drop functionality in UI

Murali Narayanaswamy
Greenhorn

Joined: May 29, 2007
Posts: 24
I have a similar requirement like in Yahoo mail Beta where you can drag any object and drop to any folder.

How is it done and would greatly appreciate if I get any of your expert comments on this

Thanks much
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Yahoo's UI widgets are open source! You can use them or just see how they did it: http://developer.yahoo.com/yui/


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Based on the forum topic, I presume you're talking about a Swing implementation, not YUI's javascript/ajax.

I would pretty much say the same thing here that I posted 18 months ago. It's almost as easy as:

JList userMessageList = new JList(...);
Jlist userFolderList = new JList(...)
userMessageList.setTransferHandler(...); // pass a handler for the drag-out
userFolderList.setTransferHandler(...); // pass a handler for the drop-into

except you have to actually write the TransferHandlers. There are other ways to do it (DragGesture/DropTarget) but TransferHandlers should be easier to use.

Do take a look at the three notes I included in the other thread. They might be helpful.


bitguru blog
 
 
subject: Drag and Drop functionality in UI