• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed in selecting multiple nodes in Jtree

 
Swetha Krish
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on typing the string in the text box, event must be triggered to search the Jtree for the string and make them selected .
Also when the string is deleted, the nodes in the tree must be deselected


 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you check the JTree API, you'll see three methods that you'll find useful: expandRow / expandPath, and getSelectionModel. The latter returns the TreeSelectionModel which has methods to clear the selection, and to add a TreePath to the selection. To convert from row number to TreePath you can use JTree's getPathForRow method.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic