tree.scrollPathToVisible(path);
    public void mousePressed(MouseEvent e)    {      Point click = e.getPoint();      TreePath path = getClosestPathForLocation(tree, click.x, click.y);      if (path != null)        {          bounds = getPathBounds(tree, path);          int row = getRowForPath(tree, path);          boolean cntlClick = isLocationInExpandControl(path, click.x, click.y);          boolean isLeaf = isLeaf(row);                    TreeCellRenderer tcr = getCellRenderer();          Icon icon;          if (isLeaf)            icon = UIManager.getIcon("Tree.leafIcon");          else if (tree.isExpanded(path))            icon = UIManager.getIcon("Tree.openIcon");          else            icon = UIManager.getIcon("Tree.closedIcon");                    if (tcr instanceof DefaultTreeCellRenderer)            {             Icon tmp = ((DefaultTreeCellRenderer) tcr).getIcon();             if (tmp != null)               icon = tmp;            }                    // add gap*2 for the space before and after the text          if (icon != null)            bounds.width += icon.getIconWidth() + gap*2;          boolean inBounds = bounds.contains(click.x, click.y);          if ((inBounds || cntlClick) && tree.isVisible(path))            {              if (inBounds)                {              selectPath(tree, path);                  if (e.getClickCount() == 2 && !isLeaf(row))                  toggleExpandState(path);                }                            if (cntlClick)                {                  handleExpandControlClick(path, click.x, click.y);                  if (cellEditor != null)                    cellEditor.cancelCellEditing();                }              else if (tree.isEditable())                startEditing(path, e);            }        }    }