This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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?