Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

select and deselect multiple nodes

 
Colleen Lynch
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hopefuly someone will know a solution.
Say for example I have 2 nodes selected in my tree and then I select another without pressing the ctrl key, therefore removing the others that were previously selected. Is there a method that will give me the nodes currently selected?
As the nodes are selected in the tree, they are added to a vector, when they are deselected, I want to remove them from the vector.
I hope someone has a solution
 
Ronnie Phelps
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in javax.swing.tree.DefaultTreeSelectionModel getLeadSelectionPath() returns the previous selection path.
 
Brian Snyder2002
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just add a mouselistener to your tree. When the tree has some sort of selection, just do
and add this to a static ArrayList or Vector in a Singleton based on whether or not it is selected.

The Singleton could then fire an event every time it gets set with the selected nodes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic