Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I shrink a Miglayout row height to zero when I hide components

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.

like image 376
PeteBrew Avatar asked Feb 02 '12 19:02

PeteBrew


2 Answers

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.

like image 189
Zach Avatar answered Sep 30 '22 19:09

Zach


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

like image 30
PeteBrew Avatar answered Sep 30 '22 20:09

PeteBrew