void (boolean toggleNodeState) { TreePath path = myTree.getSelectionPath(); if (path != null) { if (isLeaf(path)) { fireOkAction(); } else if (toggleNodeState) { if (myTree.isExpanded(path)) { myTree.collapsePath(path); } else { myTree.expandPath(path); } } } }