• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Node Selection in JTree

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic