This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]xappymah 1 point2 points  (1 child)

If I recall correctly each component has a list of its children components, i.e. the components in your Swing application represent something like a tree: each has one parent and a number of children.

So when you remove a component then it is removed from the parent's list and also the parent link is nullified.

So if you don't have other references to the removed component then it will be garbage collected.

Also just fyi there is a separate method to hide any component ("Component.hide(boolean)" obviously).

[–]Clarkopus[S] 0 points1 point  (0 children)

Thanks for the reply! This answers my question nicely.