selectPath(tree, newPath);
tree.setSelectionPath(newPath);
    public void actionPerformed(ActionEvent e)    {      TreePath currentPath = tree.getLeadSelectionPath();      int currentRow;      if (currentPath != null)        currentRow = treeState.getRowForPath(currentPath);      else        currentRow = 0;      int rows = treeState.getRowCount();      int nextRow = currentRow + 1;      int prevRow = currentRow - 1;      boolean hasNext = nextRow < rows;      boolean hasPrev = prevRow >= 0 && rows > 0;      TreePath newPath;      String command = e.getActionCommand();      if (command.equals("selectPreviousChangeLead") && hasPrev)            {          newPath = treeState.getPathForRow(prevRow);              selectPath(tree, newPath);              tree.setLeadSelectionPath(newPath);            }      else if (command.equals("selectPreviousExtendSelection") && hasPrev)            {          newPath = treeState.getPathForRow(prevRow);              tree.addSelectionPath(newPath);              tree.setLeadSelectionPath(newPath);            }      else if (command.equals("selectPrevious") && hasPrev)        {          newPath = treeState.getPathForRow(prevRow);              selectPath(tree, newPath);            }      else if (command.equals("selectNext") && hasNext)        {          newPath = treeState.getPathForRow(nextRow);              selectPath(tree, newPath);            }      else if (command.equals("selectNextExtendSelection") && hasNext)            {          newPath = treeState.getPathForRow(nextRow);              tree.addSelectionPath(newPath);              tree.setLeadSelectionPath(newPath);            }      else if (command.equals("selectNextChangeLead") && hasNext)            {          newPath = treeState.getPathForRow(nextRow);              selectPath(tree, newPath);              tree.setLeadSelectionPath(newPath);            }        }