tree.addSelectionRow(0);
selectPath(tree, new TreePath(currentVisiblePath.getPathComponent(0)));
  void updateCurrentVisiblePath()  {    if (treeModel == null)      return;    Object next = treeModel.getRoot();    Rectangle bounds = getCellBounds(0, 0, next);        // If root is not a valid size to be visible, or is    // not visible and the tree is expanded, then the next node acts    // as the root    if ((bounds.width == 0 && bounds.height == 0) || (!isRootVisible()         && tree.isExpanded(new TreePath(next))))      next = getNextNode(next);    TreePath current = null;    while (next != null)      {        if (current == null)          current = new TreePath(next);        else             current = current.pathByAddingChild(next);        do          {            TreePath path = new TreePath(getPathToRoot(next, 0));            if (tree.isVisible(path) && tree.isExpanded(path))          next = getNextNode(next);            else next = getNextSibling(next);          }        while (next != null && !tree.isVisible(new TreePath(getPathToRoot(next, 0))));      }    currentVisiblePath = current;    tree.setVisibleRowCount(getRowCount(tree));    if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 &&        currentVisiblePath != null)      tree.addSelectionRow(0);  }