This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Jtree child selection problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Jtree child selection problem" Watch "Jtree child selection problem" New topic
Author

Jtree child selection problem

Kevin Magee
Greenhorn

Joined: Feb 02, 2002
Posts: 18
hi,
I have a JTree which roughly looks like this:
0.root
1.child1
1.1.leaf
1.2.leaf
2.child2
2.1.leaf
2.2.leaf
I've added a right click JPopUpMenu in order carry out various functions on particular nodes in the tree. A different menu appear depending on whether the node is a child or a leaf. This menu uses the mouse event location in order to select the relevant node. The menu system itself works fine.
However, I'm also trying to delete and add notes to the 1st level (the child nodes in the diagram) however, I can't seem to properly select them, the root is selected instead.
here's the code:


Any ideas on how to select the correct node, any help would be greatly appreciated.
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
have you checked what tree path is returned for the call to

?
is this the path you want to select or the path that gets actually selected?
be sure that getExpandsSelectedPath() is set to true.
c
 
wood burning stoves
 
subject: Jtree child selection problem