Reputation: 4305
I have a JDialog with a JTree which includes a DefaultMutableTreeNode and its childs. I would like to have one of the nodes of tree focused when the JDialog is displayed. Just use the
tree.requestFocus();
doesn't seem to work...any ideas?
Upvotes: 1
Views: 2732
Reputation: 9380
1) If you know the row no. you can write tree.setSelectionRow(rownumber)
2) If you know the node, then tree.setSelectionPath( new TreePath(node.getPath()) );
-> http://www.coderanch.com/t/332842/GUI/java/JTree-setFocus
Upvotes: 4