private void expandAll(JTree catTree,TreePath parent,boolean expand){
  TreeNode node=(TreeNode)parent.getLastPathComponent();
  if (node.getChildCount() >= 0) {
    for (Enumeration e=node.children(); e.hasMoreElements(); ) {
      TreeNode n=(TreeNode)e.nextElement();
      TreePath path=parent.pathByAddingChild(n);
      expandAll(catTree,path,expand);
    }
  }
  if (parent.getPathCount() > 1) {
    if (expand) {
      catTree.expandPath(parent);
    }
 else {
      catTree.collapsePath(parent);
    }
  }
}

private void expandAll ( JTree catTree , TreePath parent , boolean expand ) { TreeNode node = ( TreeNode ) parent . getLastPathComponent ( ) ; if ( node . getChildCount ( ) >= 0 ) { for ( Enumeration e = node . children ( ) ; e . hasMoreElements ( ) ; ) { TreeNode n = ( TreeNode ) e . nextElement ( ) ; TreePath path = parent . pathByAddingChild ( n ) ; expandAll ( catTree , path , expand ) ; } } if ( parent . getPathCount ( ) > 1 ) { if ( expand ) { catTree . expandPath ( parent ) ; } else { catTree . collapsePath ( parent ) ; } } }
expand or collapse all nodes of the specified tree
