• Post Reply Bookmark Topic Watch Topic
  • New Topic

Node Selection in JTree  RSS feed

 
Visakh Menon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Newbie to Swing..I have a requirement of making one or more nodes (at any level) selected in a JTree. I have the reference to JTree instanse and a list of node names.
Could any one can help me with some pointers / sample code..
Thanks in advance.
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use treeSelectionModel.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION) to allow user to select multiple nodes in the Tree.
use treeSelectionModel.getSelectionPaths() that returns an array of TreePath objects. Each TreePath Object representing path to the Node from the RootElement.
 
Visakh Menon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the inputs. Let me make my needs more clear.
I have reference to a JTree. User is not going to take any action. I have to expand the tree, parse through the nodes and make a particular node selected when the name of the node matches with the name I have.
Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!