Hi Shannon,
> Right now, the way to figure out where the drop took place is to query
> the component's selection. As the drag is happening over your tree,
> Swing should be updating the selection to show where the drop will
> occur. You can query the tree's selection to see which node was
> selected when the drop occurred.
Yes, this way your suggested solution seems to work. The problem in my
special case occurs in the other case (if the user wants to drop
something inside the JPanel), because there's nothing really selected
before the drop operation takes place: the user starts the DnD with the
selection of an icon residing in the JTree. Afterwards the selected Icon
has to be dragged to a JPanel with a JGraph component into it (cf. to
http://jgraph.sourceforge.net/ ). After the drop a new cell will be
created in the graph and the data will be transfered via the two
assigned TransferHandlers. The problem is now to get the correct posion
into the graph where the new cell has bo be displayed.
> In the future, we'd like to provide a better way to indicate/query the
> drop location. This is being tracked as bug number 4468566
> (http://developer.java.sun.com/developer/bugParade/bugs/4468566.html).
Very good, thank you. But is there really no workaround? At the moment
I've absolutely no idea how to solve this problem, because I don't want
to step back to the "old" DnD mechanism in java versions prior to 1.4.
Thanks again for your help.
-Frank

Signature
Frank Dannemann Phone : +49 (0)531/295-2782
German Aerospace Center (DLR) Fax : +49 (0)531/295-2767
Simulation and Software Technology E-Mail: Frank.Dannemann@DLR.de
Shannon Hickey - Swing Team - 11 Sep 2003 03:58 GMT
Hi Frank,
> Hi Shannon,
>
[quoted text clipped - 26 lines]
>
> -Frank
There's definitely a way! I just had to do a little investigation to
figure out what it is :)
After you set the TransferHandler on your JPanel, add the following
lines of code:
// Do this AFTER setting the TransferHandler. The installation of a
// TransferHandler causes a NEW DropTarget to be installed
panel.getDropTarget().addDropTargetListener(new DropTargetListener() {
public void dragOver(DropTargetDragEvent e) {
// This point contains the point in your component where
// the cursor currently is. You can save the location for
// use in importData().
Point p = e.getLocation();
}
public void dragEnter(DropTargetDragEvent e) {}
public void dragExit(DropTargetEvent e) {}
public void drop(DropTargetDropEvent e) {}
public void dropActionChanged(DropTargetDragEvent e) {}
});
Please let me know how that works.
Regards,
Shannon
--
Shannon Hickey
shannon1@swingteam.com
Swing Team http://TheSwingConnection.com http://TheJavaTutorial.com
Java Software, a division of Sun Microsystems, Inc.
Frank Dannemann - 11 Sep 2003 10:20 GMT
Hello Shannon,
> There's definitely a way! I just had to do a little investigation to
> figure out what it is :)
Thanks a lot for the effort you put into this. I appreciate your
expert help very much! Your answer would definitely be worth the duke
dollars I assigned to this item in the "Project Swing" forum on
java.sun.com :-)
> Please let me know how that works.
It works perfectly! There's nothing to complain about ;-) Perhaps you
should add this solution in the workaround section of the bug you
opened (bug number 4468566).
Regards,
Frank

Signature
Frank Dannemann Phone : +49 (0)531/295-2782
German Aerospace Center (DLR) Fax : +49 (0)531/295-2767
Simulation and Software Technology E-Mail: Frank.Dannemann@DLR.de
Sudeep - 29 Aug 2005 10:06 GMT
Hello Franc,
I also need to drag from a JTree to a JGraph. But I'm wondering how to start
that. So it would be kind if you'd mail me a sample example at
sks_sudeep@yahoo.com. Your help would mean a lot to me.
Thanks in advance !
- Sudeep
>Hello Shannon,
>
[quoted text clipped - 15 lines]
>
>Frank