File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT / JFace and the fly likes Deselecting JTree nodes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Deselecting JTree nodes" Watch "Deselecting JTree nodes" New topic
Author

Deselecting JTree nodes

Colleen Lynch
Greenhorn

Joined: Jun 18, 2001
Posts: 15
Upon selecting a node in my JTree, the UserObject is added to a vector. If a node is deselected, how can I find out what node it is? getLastSelectedPathComponent() returns null. Is there any other method I can use or event triggered when a node is deselected?
I would really appreciate your help!!
Thanks
kate damond
Ranch Hand

Joined: Apr 17, 2001
Posts: 77
Hi,
Listen for treeSelection events. When the selction changes, you can get at at the old LeadSelection Path through the TreeSelectionEvent...

Which is the one just unselected.
Let me know if this needs more explanation,
Cheers,
Kate
Colleen Lynch
Greenhorn

Joined: Jun 18, 2001
Posts: 15
Thanks for your reply.
I also got the path of the node selected by using the method of the TreeSelectionEvent class, isAddedPath. This returns false if the node was deselected.
I now have a new problem... Hopefuly someone will know a solution. Say for example I have 2 nodes in my tree selected, 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?
thanks
 
IntelliJ Java IDE
 
subject: Deselecting JTree nodes
 
Threads others viewed
JTree
JTree
JCheckBoxes in JTree nodes
make node blink in jtree
JTree
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture