if (tree.isEditing()) tree.cancelEditing();
completeEditing();
    public void valueChanged(TreeSelectionEvent event)    {      if (tree.isEditing())        tree.cancelEditing();      TreePath op = event.getOldLeadSelectionPath();      TreePath np = event.getNewLeadSelectionPath();            // Repaint of the changed lead selection path.      if (op != np)        {          Rectangle o = treeState.getBounds(event.getOldLeadSelectionPath(),                                            new Rectangle());          Rectangle n = treeState.getBounds(event.getNewLeadSelectionPath(),                                            new Rectangle());                    if (o!=null)            tree.repaint(o);          if (n!=null)            tree.repaint(n);        }    }