wood burning stoves
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

select and deselect multiple nodes

Colleen Lynch

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

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
I agree. Here's the link: http://aspose.com/file-tools
subject: select and deselect multiple nodes
It's not a secret anymore!