code: public void setFilter(TreeModelFilter filter)
      {
          if (filter == null)
          {
              treeModel.setFilter(filter);
              for (TreePath path : expandedPaths)
              {
                  tree.expandPath(path);
              }
          }
          else
          {
              tree.removeTreeExpansionListener(expandedPathsListener);
              treeModel.setFilter(filter);
              
              //long before = System.nanoTime();
              JTrees.expandAllFixedHeight(tree);
              //long after = System.nanoTime();
              //System.out.println("Expanding rows took "+(after-before)/1e6);
              
              tree.addTreeExpansionListener(expandedPathsListener);
          }
      }
docs: Set the filter of the model for the tree. All nodes of the
  filtered tree will be expanded. If the given filter is
  <code>null</code>, then all nodes will be displayed and
  the last expansion state of the unfiltered tree will be
  restored.
  
  @param filter The {@link TreeModelFilter}