-
Enhancement
-
Resolution: Fixed
-
P4
-
1.3.0, 1.4.1, 1.4.2
-
tiger
-
x86
-
windows_nt, windows_xp
Name: rmT116609 Date: 10/10/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
I've written a JTree that supports drag&drop. I implemented the
DropTargetListener.dragOver(DropTargetDragEvent) that it selects the current
node that the dragging node moves over. Now, I want to check if this
current/selected node is a valid drop target (node). For this reason, I need to
get the current transferable to check wether source and target nodes
are "compatible". For this reason I did a DropTargetDragEvent.getTransferable()
(just like DropTargetDropEvent.getTransferable()) but this method is not
available in DropTargetDragEvent! Playing with different DataFlavors is not
enough, there are objects of the same flavour but with different properties.
And the dropping sequence is dependend on this properties, so I need to have
the transferable to check for additional values.
Can we expect to have DropTargetDragEvent.getTransferable() in the next SDK or
is there another solution for this problem?
when I implemented the DropTargetListener, I came to dragOver(). In this
method I want to check if the dragged node is allowed to be dropped on the
current "under" node. SO, just like I did in with a DropTargetDropEvent, I
called "getTransferable()" to inspect the nodes and do further checking. But
the compiler said that getTransferable() is not availabe in
DropTargetDragEvent!
But I need this to check whether the node is "compatible" with the to be
dropped on node. (Application logic: only specific nodes (with specific
properties) are allowed to be dropped - even of the same falvour!).
Here's the code with the not working (but needed) part in comments:
--------------------------------------
/**
* Implements DropTargetListener.
* Called when a drag operation is ongoing on the DropTarget.
*/
public void dragOver(DropTargetDragEvent event) {
//System.out.println("DropTargetListener.dragOver() ...");
Point mouseLoc = event.getLocation();
TreePath path = this.getPathForLocation(mouseLoc.x, mouseLoc.y);
if (path != null) {
VegasNode selectedTarget = (VegasNode)
path.getLastPathComponent();
selectNode(selectedTarget);
//unfortunately, the following method does not exist: !!!
// Transferable tr = event.getTransferable();
// if (tr.isDataFlavorSupported(VegasNode.NODE_FLAVOR)) { //is
this a VegasNode?
// VegasNode dragNode = (VegasNode)
tr.getTransferData(VegasNode.NODE_FLAVOR);
// Utils.debug("check here for valid drop sequence:
dragNode="+dragNode+", dropNode="+selectedTarget);
// //todo: check type of both VegasNodes if they are
compatibe ...
// }
}
}//dragOver()
(Review ID: 107743)
======================================================================
- duplicates
-
JDK-5018712 NO WAY TO TELL WHAT IS BEING DRAGGED UNTIL DROP OCCURS
- Closed
-
JDK-4938575 DropTargetListener cannot get dragged Transferable
- Closed
-
JDK-4357494 DropTargetDragEvent.getTransferable() is missing!
- Closed
- relates to
-
JDK-4248542 DropTargetListener can't access the transferable in dragOver and dragEnter
- Resolved
-
JDK-4942851 canImport should carry Transferable in TransferHandler
- Resolved