code: public static void expandAllFixedHeight(JTree tree)
      {
          // Determine a suitable row height for the tree, based on the 
          // size of the component that is used for rendering the root 
          TreeCellRenderer cellRenderer = tree.getCellRenderer();
          Component treeCellRendererComponent = 
              cellRenderer.getTreeCellRendererComponent(
                  tree, tree.getModel().getRoot(), false, false, false, 1, false);
          int rowHeight = treeCellRendererComponent.getPreferredSize().height + 2;
          tree.setRowHeight(rowHeight);
          
          // Temporarily remove all listeners that would otherwise
          // be flooded with TreeExpansionEvents
          List<TreeExpansionListener> expansionListeners =
              Arrays.asList(tree.getTreeExpansionListeners());
          for (TreeExpansionListener expansionListener : expansionListeners)
          {
              tree.removeTreeExpansionListener(expansionListener);
          }
          
          // Recursively expand all nodes of the tree
          TreePath rootPath = new TreePath(tree.getModel().getRoot());
          expandAllRecursively(tree, rootPath);
          
          // Restore the listeners that the tree originally had
          for (TreeExpansionListener expansionListener : expansionListeners)
          {
              tree.addTreeExpansionListener(expansionListener);
          }
          
          // Trigger an update for the TreeExpansionListeners
          tree.collapsePath(rootPath);
          tree.expandPath(rootPath);
      }
docs: Expand all rows of the given tree, assuming a fixed height for
  the rows.
  
  @param tree The tree