aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes navigate a JTree with JButton(s) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "navigate a JTree with JButton(s)" Watch "navigate a JTree with JButton(s)" New topic
Author

navigate a JTree with JButton(s)

Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

Hi,

I have a JTree representing a simple hierarchy. I also have four buttons to navigate through the tree (first , previous, next,last JButton(s))

I want to implement the following functionality :

if i click a given button the current selected node in JTree should be set accordinely to chosen button : ex if i click next button ; then JTree should select the node directly under current selected node ..and so for each button.

can some one suggest some code to do that ?

thanking you.
Alice Corman
Greenhorn

Joined: Jun 21, 2006
Posts: 19
Just a thought, but if your tree nodes extend DefaultMutableTreeNode you might be able to use the built in methods like getPreviousNode(), getNextNode(), to obtain the previous/next node in preorder traversal. Once you have the correct node, just make sure the node is visible/expanded in the JTree.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: navigate a JTree with JButton(s)