DefaultTreeModel -- Adding, Removing and Updating Nodes
By Scott Hommel-Oracle on May 16, 2008
Collin wasted no time creating such an example. Unfortunately, resources being what they are, I wasn't able to get engineering cycles for reviewing the example. Because we generally don't include material that hasn't been reviewed by engineering, it was backburnered.
Meanwhile, Collin posted his example and some accompanying text, The Secret Life of a DefaultTreeModel on JavaLobby.
Collin has now posted his example on the JavaTutorials forum!
When you compile and run the example (it will run under JDK 5) it brings up a panel containing a tree with a root node. When you open the root node you'll see three child nodes. At this point you can right-click any of the nodes (control-click on a Mac) and you can add 50 children to the current selection, remove the current selection, or modify the text on the current selection.
Thanks for this very useful example, Collin!
-- Sharon Zakhour