if (e.getActionCommand().equals("selectParent"))
String command = (String) getValue(Action.NAME); if (command.equals("selectParent"))
    public void actionPerformed(ActionEvent e)    {      TreePath current = tree.getLeadSelectionPath();      if (current == null)        return;      if (e.getActionCommand().equals("selectParent"))        {          if (current == null)            return;          if (tree.isExpanded(current))            {              tree.collapsePath(current);            }          else            {              // If the node is not expanded (also, if it is a leaf node),              // we just select the parent. We do not select the root if it              // is not visible.              TreePath parent = current.getParentPath();              if (parent != null &&                   !(parent.getPathCount()==1 && !tree.isRootVisible()) )                tree.setSelectionPath(parent);            }        }      else if (e.getActionCommand().equals("selectChild"))        {          Object node = current.getLastPathComponent();          int nc = treeModel.getChildCount(node);          if (nc == 0 || treeState.isExpanded(current))            {              // If the node is leaf or it is already expanded,              // we just select the next row.              int nextRow = tree.getLeadSelectionRow() + 1;              if (nextRow <= tree.getRowCount())                tree.setSelectionRow(nextRow);            }          else            {              tree.expandPath(current);            }        }    }