/** * Overridden to make clone public. Returns a shallow copy of this node; the new node has no * parent or children and has a reference to the same user object, if any. * * @return a copy of this node */ public Object clone() { DefaultMutableTreeNode newNode; try { newNode = (DefaultMutableTreeNode) super.clone(); // shallow copy -- the new node has no parent or children newNode.children = null; newNode.parent = null; } catch (CloneNotSupportedException e) { // Won't happen because we implement Cloneable throw new Error(e.toString()); } return newNode; }