I dunno where your problem is but it is probably safe to assume it is outside of the code you have provided. I suspect your y coordinate is wrong. You might look at the context for your DropTargetDropEvent to make sure you have the right component (should be the JTree, not the JList). Try dragging an object first within the JTree and then from the JList to the JTree. Drop them both on the same location to see if the y coordinates are different. If they are different, is the y-discrepancy (the distance between the location where you drop the JList object and the location where it appears) the same as the difference in the y-coordinates of the JList and the JTree? If so this would also suggest that relative coordinates are being computed using the wrong component.
Lee Haslup
At 09:59 AM 6/9/2003 +0200, you wrote:
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
_______________________________________________ Juglist mailing list [EMAIL PROTECTED] http://trijug.org/mailman/listinfo/juglist_trijug.org
