I'm experiencing a problem.

I am using the method of the JTree class called
getClosestPathForLocation( int x , int y );

When I drag and drop nodes around a JTree, it works perfectly.

But when I try drag in from a JList situated above the tree, then the drop
seems to consistently go a considerable amount above the expected drop
point.

Below is the method which I use to drop into the tree (from the JList), can
someone tell me if I'm doing something wrong


public void handleDragEvent(Point oldPoint,Point newPoint){

///oldPoint is always correct
///newPoint seems to be correct

 TreePath path =  treePanel.getTree().getClosestPathForLocation( newPoint.x
, newPoint.y );//create a treepath from the closest point, this method works
//perfectly when used internally in the JTree

MutableTreeNode node = (MutableTreeNode)path.getLastPathComponent();

    // Create new node
     MutableTreeNode newNode = new DefaultMutableTreeNode("insert me !");

    // Insert new node as last child of node
     treePanel.getModel().insertNodeInto(newNode, node,
node.getChildCount());

     treePanel.getTree().validate();
     treePanel.getTree().repaint();

 }




_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to