tree.scrollPathToVisible(tree.getLeadSelectionPath());
    public void actionPerformed(ActionEvent e)    {      if (tree != null)        {          String command = (String) getValue(Action.NAME);          if (command.equals("selectFirst"))            {              ensureRowsAreVisible(0, 0);              tree.setSelectionInterval(0, 0);            }          if (command.equals("selectFirstChangeLead"))            {              ensureRowsAreVisible(0, 0);              tree.setLeadSelectionPath(getPathForRow(tree, 0));            }          if (command.equals("selectFirstExtendSelection"))            {              ensureRowsAreVisible(0, 0);              TreePath anchorPath = tree.getAnchorSelectionPath();              if (anchorPath == null)                tree.setSelectionInterval(0, 0);              else                {                  int anchorRow = getRowForPath(tree, anchorPath);                  tree.setSelectionInterval(0, anchorRow);                  tree.setAnchorSelectionPath(anchorPath);                  tree.setLeadSelectionPath(getPathForRow(tree, 0));                }            }          else if (command.equals("selectLast"))            {              int end = getRowCount(tree) - 1;              ensureRowsAreVisible(end, end);              tree.setSelectionInterval(end, end);            }          else if (command.equals("selectLastChangeLead"))            {              int end = getRowCount(tree) - 1;              ensureRowsAreVisible(end, end);              tree.setLeadSelectionPath(getPathForRow(tree, end));            }          else if (command.equals("selectLastExtendSelection"))            {              int end = getRowCount(tree) - 1;              ensureRowsAreVisible(end, end);              TreePath anchorPath = tree.getAnchorSelectionPath();              if (anchorPath == null)                tree.setSelectionInterval(end, end);              else                {                  int anchorRow = getRowForPath(tree, anchorPath);                  tree.setSelectionInterval(end, anchorRow);                  tree.setAnchorSelectionPath(anchorPath);                  tree.setLeadSelectionPath(getPathForRow(tree, end));                }            }        }    }