Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree setFocus()  RSS feed

 
Chinmay Bajikar
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i setFocus() to a node in JTree?
 
Vinod Venugopal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say "setFocus to a node" are you implying showing a node selected?
In that case, you can do so by:
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()) );
Then if you want to set focus to the tree pane then call pane.setFocus where pane is the container containing the tree.
Vinod
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!