Forums Register Login
Adding a child to a node after previously removing all children?
I remove node's chidren by calling removeAllChidren(). This seems to work fine. However, if I try to add a child after doing thing, all of the previously removed children come back? My code snippet is below:

//remove node's children
//add a Child
DefaultMutableTreeNode junk = new DefaultMutableTreeNode("junk");

How do I add a new child to a node but not have the removed children come back at the same time? Are these values stored in an array that i have to edit?

Tell the JTree model. If you are using DefaultTreeModel it has some handy methods for this such as nodesWereRemoved.

This thread has been viewed 584 times.

All times above are in ranch (not your local) time.
The current ranch time is
Oct 18, 2018 06:32:23.