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).
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