[Logo]
Forums Register Login
Adding a child to a node after previously removing all children?
Hi,
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
node.removeAllChildren();
//add a Child
DefaultMutableTreeNode junk = new DefaultMutableTreeNode("junk");
node.add(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?

Thanks!
Tell the JTree model. If you are using DefaultTreeModel it has some handy methods for this such as nodesWereRemoved.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 17, 2017 23:57:32.