How to get the selected nodes of a JTree?
The following example show how to use the
JTree.getSelectionPaths() method to get the selected node of a
JTree component. This method returns an array of
TreePath objects. In the case to get the last node in the path we can call the
In the code below when you pressed the button the listener gets the selection paths and print out the last path component of the selected nodes.