Possible Duplicate:
JTree: how to get the text of selected item?
1In C# there's TreeView_afterSelect event, and i ask if in java is something like that ? I used : hierarchyPropertyChange
but it runs two times...
Possible Duplicate:
JTree: how to get the text of selected item?
1In C# there's TreeView_afterSelect event, and i ask if in java is something like that ? I used : hierarchyPropertyChange
but it runs two times...
You can use a TreeSelectionListener
:
tree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode selectedNode =
(DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
...
}
});
Returns the last path component of the selected path.
It does not say "get the path that was selected previously." –
Rocketeer © 2022 - 2024 — McMap. All rights reserved.