TreePath path = new TreePath(getPathToRoot(last, 0));
Object node = current.getLastPathComponent(); int nc = treeModel.getChildCount(node); if (nc > 0) node = treeModel.getChild(node, 0);
    public void actionPerformed(ActionEvent e)    {      Object last = tree.getLeadSelectionPath().getLastPathComponent();      if (e.getActionCommand().equals("selectParent"))        {          TreePath path = new TreePath(getPathToRoot(last, 0));          Object p = getParent(treeModel.getRoot(), last);          if (!treeModel.isLeaf(last))            toggleExpandState(path);          else if (p != null)            selectPath(tree, new TreePath(getPathToRoot(p, 0)));        }      else if (e.getActionCommand().equals("selectChild"))        {          TreePath path = new TreePath(getPathToRoot(last, 0));          if (!treeModel.isLeaf(last))            toggleExpandState(path);          else            {              Object next = getNextVisibleNode(last);              if (next != null)                selectPath(tree, new TreePath(getPathToRoot(next, 0)));            }        }    }