How to deep copy a Binary Tree?

try class Node { private String value; private Node left; private Node right; public Node(String value, Node left, Node right) { this.value = value; … } Node copy() { Node left = null; Node right = null; if (this.left != null) { left = this.left.copy(); } if (this.right != null) { right = this.right.copy(); } … Read more

Get Edited TreeNode from a CellEditorListener

It appears that you want to edit the name of a Resource in a DefaultMutableTreeNode. As you’ve found, the source of the ChangeEvent sent to editingStopped() in not a DefaultTreeCellEditor; it is the editor’s (anonymous) UI delegate. Instead, override getCellEditorValue() in your DefaultTreeCellEditor, as shown below. The DefaultTreeCellRenderer simply calls toString(), via convertValueToText(), which accesses … Read more