*
The moose likes Swing / AWT / SWT and the fly likes JTree - Have to resort to AWT DnD? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree - Have to resort to AWT DnD?" Watch "JTree - Have to resort to AWT DnD?" New topic
Author

JTree - Have to resort to AWT DnD?

James Clark
Greenhorn

Joined: May 10, 2010
Posts: 3
Hi all,

I want to drag a leaf node from a JTree onto a custom component that will generate an image representing that leaf node in the position corresponding to where the drop occurred. By this, I mean I first have a blank workspace, until I drag a node from the tree onto the workspace and it draws an image in the centre of the workspace. I then drag another node to the right of the image currently on the workspace. The insertion point is highlighted by an insertion pointer/line appearing to the right of the current image. After releasing the drop, another image is drawn in the correct position, next to the old image, filling the space appropriately.

This image should hopefully show the kind of thing I want to accomplish:



I also would like to have a representation displayed whilst dragging the node.

A solution to this that may work is to use AWT DnD, utilise the Glass pane to draw the image whilst dragging and then utilise an implementation of DropTargetListener to get the location of the drag and do the insertion point highlighting etc.

I'd like to use the Swing DnD if possible but from looking around, it doesn't seem to offer the power or flexibility to support what I want to do .

Is the AWT solution plausible? Any better solutions?

Thanks,
James


 
wood burning stoves
 
subject: JTree - Have to resort to AWT DnD?
 
Similar Threads
JTree
maintain action history of drag and drop in jtree
DND from JTree to JTable
Drag cursor not changing, but drop succeeding.
Swing DnD within JTree using Objects?