selectPath(tree, current.getParentPath());
{ if (current == null) return;  if (tree.isExpanded(current)) { tree.collapsePath(current); } else {    TreePath parent = current.getParentPath(); if (parent != null && !(parent.getPathCount()==1 && !tree.isRootVisible()) ) tree.setSelectionPath(parent); } }
    public void actionPerformed(ActionEvent e)    {      TreePath current = tree.getLeadSelectionPath();      if (current == null)        return;      if (e.getActionCommand().equals("selectParent"))        selectPath(tree, current.getParentPath());      else if (e.getActionCommand().equals("selectChild"))        {          Object node = current.getLastPathComponent();          int nc = treeModel.getChildCount(node);          if (nc > 0)            node = treeModel.getChild(node, 0);          TreePath path = current.pathByAddingChild(node);          selectPath(tree, path);        }    }