Hi ,I am trying to perform a drag-and-drop feature on the JTree .
Now encounter a problem , it is :
My custom tree is in a scrollpane .
So during drag and drop ,
in the DropTargetListener , dragOver Event
public void dragOver(DropTargetDragEvent dtde){
// this method get the point in obsolute coordinate .
Point p = dtde.getLocation();
// Then want to get the current TreeNode under the point of the mouse
// in this method , the (x, y) seems to need to use the relative coordinate .
// now it should provide the point base on the scrollpane .
TreePath path = TreeView.this.getPathForLocation(p.x, p.y);
// Then the path is null , even the mouse is over a treenode .
// coz the TreeView is added in a scrollPane and
// the scrollPane is added on another panel .
...
}
Any one help me to solve this problem ? Or tell me how to deal with it ...
Any help is appreciated .
Thank you in advance .