int row = 0; Object dest = path.getLastPathComponent(); int rowCount = getRowCount(tree); if (currentVisiblePath != null) { Object[] nodes = currentVisiblePath.getPath(); while (row < rowCount) { if (dest.equals(nodes[row])) return row; row++; } } return -1;
return treeState.getRowForPath(path);
  public int getRowForPath(JTree tree, TreePath path)  {    int row = 0;    Object dest = path.getLastPathComponent();    int rowCount = getRowCount(tree);    if (currentVisiblePath != null)      {        Object[] nodes = currentVisiblePath.getPath();        while (row < rowCount)          {            if (dest.equals(nodes[row]))    return row;            row++;                    }      }    return -1;  }