I have a simple Miglayout dialog with rows consisting of JLabels and JTextFields. The visiblility of a number of the components is set depending on the circumstances. However, when they are hidden the row height remains the same leaving a blank area.
I have set the min row height to 0px and also have other rows set to 'grow', but this doesn't seem to help. Surely, if a row can be 0px high and its contents are hidden, then it should shrink shouldn't it? Obviously I'm missing something!
Any help much appreciated.
You can set the hidemode of the layout to prevent invisible components from affecting the layout.
From http://migcalendar.com/miglayout/cheatsheet.html :
Sets the default hide mode for the layout. This hide mode can be overridden by the component constraint. The hide mode specified how the layout manager should handle a component that isn't visible. The modes are: 0 - Default. Means that invisible components will be handled exactly as if they were visible. 1 - The size of an invisible component will be set to 0, 0. 2 - The size of an invisible component will be set to 0, 0 and the gaps will also be set to 0 around it. 3 - Invisible components will not participate in the layout at all and it will for instance not take up a grid cell.
Why is it that I can only find answers to my problems after I post queries online? Seems I overlooked the following QA: Force MigLayout shrink like GridBagLayout for hidden Objects
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With