File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTree setFocus()

 
Chinmay Bajikar
Ranch Hand
Posts: 159
  • 0
  • 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
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic