I have some Java Swing components whose visible property is set to false. When they are not visible I do not want them to take up any space in the layout. What is the best way to accomplish this?
I am looking to emulate the behavior of WPF's Visibility.Collapsed.
EDIT: I am using MiGLayout. As kiheru describes in the answer, the problem I was having is particular to MiGLayout, not Swing layouts in general.
MigLayouttreats invisible components by default the same way as visible components. You need to specifyhidemodefor other kind of behaviour. From the documentation, the possible values are: