Getting Coordinates Of Selected JTree Node
Hi,
I have a JTree where user can edit the XML nodes. User can edit the node by double clicking on the node or by pressing enter on the node.
When the user double clicks the node i am able to retrieve the x and y coordinates but when the users presses enter i am not able to retrieve the coordinates where the users presses the enter.
Is there any method of JTree where i can fetch the coordinates of a selected node or is there any method of fetching coordinates on keypress.
Thanks in advance,
Cheers :-)
Akshat
Ans: Getting the coordinates of a selected JTree Node
// xmlTree is the instace of JTree.
Point p = xmlTree.getRowBounds(xmlTree.getRowForPath(currentSelection)).getLocation();
// Now convert this points to screen points
SwingUtilities.convertPointToScreen(p, this);
Cheers
Akshat