Getting Coordinates Of Selected JTree Node

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Getting Coordinates Of Selected JTree Node

  1. #1
    Join Date
    Dec 2005

    Getting Coordinates Of Selected JTree Node


    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 :-)
    Last edited by akkiboys; 01-25-2006 at 01:52 AM.

  2. #2
    Join Date
    Dec 2005

    Wink 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);



Similar Threads

  1. Replies: 1
    Last Post: 12-15-2005, 11:21 AM
  2. JTree & iterating through all selected Nodes
    By JamesOfOOST in forum Java
    Replies: 2
    Last Post: 03-14-2005, 10:05 AM
  3. Replies: 0
    Last Post: 10-19-2001, 02:28 PM
  4. Replies: 0
    Last Post: 10-17-2001, 12:46 PM
  5. EMERGENT.... double linked list
    By mary in forum Java
    Replies: 0
    Last Post: 07-20-2001, 08:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center