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
Re: JTree Programmatic Node Expansion and Selection Probelm
Hi Bob
Have read your post but do not see any answer to your problem.
I am in exactly the same position and have spent weeks on this problem with no solution. My tree path is correct, the "internal" tree structure has selected the required treepath node but the tree wont expand and display the selected path. I am stuck!! Have you found a solution? If so I would love to hear from you.
Kind regards
Karl
Re: JTree Programmatic Node Expansion and Selection Probelm
The question was asked more than 5 years ago, and the member hasn't been here for nearly 3 years.
Don't post to old dead threads and don't hijack another poster's thread. When you have a question, start your own thread; they're free. But before you do that, go through a few links:
Forum Rules
http://www.java-forums.org/forum-gui...w-members.html
BB Code List - Java Programming Forum - Learn Java Programming
SSCCE : Java Glossary
db
THREAD CLOSED