selectPath(tree, new TreePath(getPathToRoot(prev, 0)));
selectPath(tree, newPath);
    public void actionPerformed(ActionEvent e)    {      Object last = tree.getLeadSelectionPath().getLastPathComponent();      if (e.getActionCommand().equals("selectPreviousChangeLead"))        {          Object prev = getPreviousVisibleNode(last);          if (prev != null)            {              TreePath newPath = new TreePath(getPathToRoot(prev, 0));              selectPath(tree, new TreePath(getPathToRoot(prev, 0)));              tree.setLeadSelectionPath(newPath);            }        }      else if (e.getActionCommand().equals("selectPreviousExtendSelection"))        {          Object prev = getPreviousVisibleNode(last);          if (prev != null)            {              TreePath newPath = new TreePath(getPathToRoot(prev, 0));              tree.addSelectionPath(newPath);              tree.setLeadSelectionPath(newPath);            }        }      else if (e.getActionCommand().equals("selectPrevious"))        {          Object prev = getPreviousVisibleNode(last);          if (prev != null)            {              TreePath newPath = new TreePath(getPathToRoot(prev, 0));              selectPath(tree, new TreePath(getPathToRoot(prev, 0)));            }        }      else if (e.getActionCommand().equals("selectNext"))        {          Object next = getNextVisibleNode(last);          if (next != null)            {              TreePath newPath = new TreePath(getPathToRoot(next, 0));              selectPath(tree, newPath);            }        }      else if (e.getActionCommand().equals("selectNextExtendSelection"))        {          Object next = getNextVisibleNode(last);          if (next != null)            {              TreePath newPath = new TreePath(getPathToRoot(next, 0));              tree.addSelectionPath(newPath);              tree.setLeadSelectionPath(newPath);            }        }      else if (e.getActionCommand().equals("selectNextChangeLead"))        {          Object next = getNextVisibleNode(last);          if (next != null)            {              TreePath newPath = new TreePath(getPathToRoot(next, 0));              selectPath(tree, newPath);              tree.setLeadSelectionPath(newPath);            }        }    }