MiG InfoCom MiG Layout Quick Start Guide User Manual

Page 6

Advertising
background image

Note that a docked component "cuts off" that part which means that the ordering of the docking components
is important for how the corners are used. If the comp4E component was moved first in the code the table
would look like this instead:

comp1N

comp2W

comp1

comp2

comp3

comp4

comp3S

comp4E

Docking components is a very good and easy way to layout panels but its usages are many. You can get
spacing around the docking components by using normal Component Gaps as described above.

Growing and Shrinking Components Depending on Available Space

The grow and shrink behavior for both columns/rows and components are extremely customizable with MiG
Layout. You can divide them into grow/shrink priority groups, so that one or a group of grows/shrinks to their
max/min size before the next groups are even considered. It is also possible to set the weight for how keen
they should be to grow/shrink within that priority group. See the documentation for a thorough explanation
but it is safe to say that you will not be out of options.

Components and rows/columns will by default shrink to their minimum sizes if space is scarce. A
column/row's minimum size is by default the largest minimum size of its components.

What is normally enough to know is how to make a component or row/column grow and/or disallow it to
shrink. Examples:

MigLayout layout = new MigLayout(
"", // Layout Constraints
"[grow][][grow]", // Column constraints
"[][shrink 0]"); // Row constraints

And for components:

panel.add(comp, "growx") // Grow horizontally. Same as "growx 100"

panel.add(comp, "growy") // Grow vertically. Same as "growy 100"

panel.add(comp, "grow") // Grow both. Same as "grow 100 100"

panel.add(comp, "shrink 0") // Will not shrink.

Components will never "push" the column/row's size to be larger using the grow keyword.

© 2009 MiG InfoCom AB

Advertising