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();
...
}
});