my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes select and deselect multiple nodes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "select and deselect multiple nodes" Watch "select and deselect multiple nodes" New topic
Author

select and deselect multiple nodes

Colleen Lynch
Greenhorn

Joined: Jun 18, 2001
Posts: 15
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

Joined: Mar 12, 2001
Posts: 329
in javax.swing.tree.DefaultTreeSelectionModel getLeadSelectionPath() returns the previous selection path.
Brian Snyder2002
Greenhorn

Joined: Jan 24, 2002
Posts: 11
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.


Java Developer<br />SCJ2P
 
Consider Paul's rocket mass heater.
 
subject: select and deselect multiple nodes