File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JTree setFocus() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree setFocus()" Watch "JTree setFocus()" New topic
Author

JTree setFocus()

Chinmay Bajikar
Ranch Hand

Joined: Dec 08, 2001
Posts: 159
How do i setFocus() to a node in JTree?


The strength of the Wolf is the pack & the strength of the pack is the wolf....Rudyard Kipling
Vinod Venugopal
Ranch Hand

Joined: Dec 06, 2000
Posts: 148
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


- Vinod<br />-------<br />SCJP2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTree setFocus()
 
Similar Threads
JTree
JTree
JTree
JTree
JTree