Hi

I have a program that has a JTree that lists of all the directories on my computer. I also have a JList in and an add button. Now I am trying to select or highlight a directory in the JTree, click the add Button and then update the JList with the name of the node (Directory) I have clicked. I have looked at mouse listeners actionlisteners and tree selectionListeners but cannot come up with anything that seems feasible.


Any suggestions may be helpful

Manythanks

Assuming you only allow a single selection in the JTree you can use: JTree.getSelectionPath.

It returns a TreePath which basically holds a list of the hierarchy that is selected. Then you can use TreePath.getLastPathComponent to get the name of the node you're looking for.

HTH

commented: Helpful answer. +12