int count = 0; if (treeModel != null) { Object node = treeModel.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath((getPathToRoot(node, 0))))) node = getNextNode(node);  while (node != null) { count++; node = getNextVisibleNode(node); } } return count;
if (currentVisiblePath != null) return currentVisiblePath.getPathCount(); return 0;
  public int getRowCount(JTree tree)  {    int count = 0;    if (treeModel != null)      {        Object node = treeModel.getRoot();        if (!tree.isRootVisible()            && tree.isExpanded(new TreePath((getPathToRoot(node, 0)))))          node = getNextNode(node);        while (node != null)          {            count++;            node = getNextVisibleNode(node);          }      }    return count;  }