File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JTree - explicitly select a node Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree - explicitly select a node" Watch "JTree - explicitly select a node" New topic

JTree - explicitly select a node

Deyna Cegielski
Ranch Hand

Joined: Nov 24, 2004
Posts: 60
my help interface consists of a split pane with a jtree on the left and a jeditorpane on the right.

clicking on a node in the tree heirarchy loads the relevant page into the editorpane

ive added a toolbar that lets you move back and forward through your visited page history (similar to ie). the problem is the last node selected before you start using the back and forward buttons remains selected throughout.

is there a method that explicitly highlights a particular node item, so when a user clicks back, the node that is highlighted becomes deselected and the node whos page has just loaded becomes highlighted.

[ April 21, 2006: Message edited by: Deyna Cegielski ]
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
In the JTree api there are a number of methods that will change the selection state, egs, setSelectedRow, removeSelectionRow, setSelectionPath, cancelSelection.
Deyna Cegielski
Ranch Hand

Joined: Nov 24, 2004
Posts: 60
thanks i must have missed those, pinpointing the method your after cna be quite tricky at times
I agree. Here's the link:
subject: JTree - explicitly select a node
It's not a secret anymore!