public static int expandJTreeNode(javax.swing.JTree tree,javax.swing.tree.TreeModel model,Object node,int row,int depth){
  if (node != null && !model.isLeaf(node)) {
    tree.expandRow(row);
    if (depth != 0) {
      for (int index=0; row + 1 < tree.getRowCount() && index < model.getChildCount(node); index++) {
        row++;
        Object child=model.getChild(node,index);
        if (child == null)         break;
        javax.swing.tree.TreePath path;
        while ((path=tree.getPathForRow(row)) != null && path.getLastPathComponent() != child)         row++;
        if (path == null)         break;
        row=expandJTreeNode(tree,model,child,row,depth - 1);
      }
    }
  }
  return row;
}

public static int expandJTreeNode ( javax . swing . JTree tree , javax . swing . tree . TreeModel model , Object node , int row , int depth ) { if ( node != null && ! model . isLeaf ( node ) ) { tree . expandRow ( row ) ; if ( depth != 0 ) { for ( int index = 0 ; row + 1 < tree . getRowCount ( ) && index < model . getChildCount ( node ) ; index ++ ) { row ++ ; Object child = model . getChild ( node , index ) ; if ( child == null ) break ; javax . swing . tree . TreePath path ; while ( ( path = tree . getPathForRow ( row ) ) != null && path . getLastPathComponent ( ) != child ) row ++ ; if ( path == null ) break ; row = expandJTreeNode ( tree , model , child , row , depth - 1 ) ; } } } return row ; }
expands a given node in a jtree .
