Originally Posted by
KevinWorkman
That situation is, funnily enough, called an "island of isolation", and you can google that for more info. Basically those objects are unreachable and are eligible for garbage collection.
Huh... I did not know that. Thank you kindly, I'll go read up on that
Originally Posted by
KevinWorkman
I'm 90% sure that the objects are no longer reachable and will become eligible for garbage collection. The only reason I'm not saying I'm 100% sure is the off chance that the children of removed nodes are added to the parent of the removed nodes (this seems unlikely but not impossible, I haven't read the documentation), or in case you have code that's keeping a reference to them around (say, an ArrayList of the nodes you've created). If neither of those cases is true, then they're unreachable.
If that's the only case of concern, then I don't suspect that's the case. If the children of a removed node are added to the parent of the removed node, then they'd show up in the graphics representation when calling treeModel.nodeHasChanged(removedNode). I had this into the programme prior to figuring out how to do node addition and subtraction using an instance of DefaultTreeModel rather than by using the DefaultTreeNode "add" and "remove" methods. When I tried it, the nodes did not show up.
Now, I'm presuming that the nodes will show up in the graphical representation as that's what I understand the nodeHasChanged method to do - update the node to show changes to the JTree after it. If the nodes were still attached to each other, they should show up. If they don't show up, then that must mean they're not attached to any node that traces back to the root. And since I THINK JTree nodes are only ever attached to each other and not to the JTree (aside from the Root), then that means they should be unreferenced, right?
Sorry that what I say is so full of conjecture, but it does make me sort of happy with how I have things set up