1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
jTree.addTreeWillExpandListener(new TreeWillExpandListener() {
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
// recuperation du treepath de la racine
TreePath rootTreePath = new TreePath(root.getPath());
// si on double clique sur la racine alors on ne la collapse pas
if (event.getPath().equals(rootTreePath)) {
throw new ExpandVetoException(event);
}
}
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
}
}); |