View Single Post
  #1 (permalink)  
Old 01-16-2008, 09:27 PM
hemanthjava hemanthjava is offline
Member
 
Join Date: Dec 2007
Posts: 14
hemanthjava is on a distinguished road
JTree Programmatic Node Expansion and Selection Probelm
I've read plenty of java Swing forums or questions and none of them have the right answers. I am trying to dynamically select a node in a JTree by searching for it using a search panel based on its property.

My jtree allows single selection model. (SINGLE_TREE_SELECTION).

Code:
jTree.setExpandsSelectedPaths(true); // jTree.expandPath(treePath); jTree.setSelectionPath(treePath); jTree.scrollPathToVisible(treePath);

I know the node is being selected and a call to jTree.getSelectionPath() shows the expected treePath. The problem is that graphically the treePath is neither expanded nor the specific searched node is highlighted.

TreePath is correct, and the node is being selected. The branch is just not being expanded and the node is not being highlighted. The node is not highlighted even when the branch is already in an expanded state.

Can anyone please help.

I am using Java 1.5

Thanks,
Bob
Reply With Quote
Sponsored Links