Specifying gaps, Grid gaps, Component gaps – MiG InfoCom MiG Layout Quick Start Guide User Manual

Page 3

Advertising
background image

panel.add(comp1, "cell 0 0");
panel.add(comp2, "cell 1 0 2 1"); // "cell column row width height"
panel.add(comp3, "cell 3 0");
panel.add(comp4, "cell 0 1 4 1");

comp1

comp2

comp3

comp4

Specifying Gaps

Generally gaps are added where they make sense and this is performed on a platform by platform basis. For
instance Mac OS X will have bigger gaps than Windows or Linux in general. There are two kinds of gaps.
Grid row gaps and Component gaps. They default to proper values but you can change them however you
like.

Grid gaps

In the grid illustrations above they are the small spacing columns and rows between the real columns and
rows. Their size can be set in the column and rows constraints when creating the layout manager (or set on
the layout manager object afterwards). E.g.

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

would create something like this:

comp1

comp2

comp3

comp4

where the bigger spacing row and column is 20 pixels. You can of course use any unit to specify the size but
the default default is pixels (you can change this though). For instance "20mm" will make it 20 millimeters
wide.

Note that from 2.5 you can specify the gap when using the "wrap" keyword. E.g. "wrap 15px"

The space between the square brackets [

(here..)

] is the place where you specify the row and component

constraints such as alignment and size. More on this later.

Component gaps

The only situation where there is a default component gap > 0 is between components in the same (thus
split) cell. You can however change this by specifying a gap size when adding the component. Gaps around
components is the distance to the closest edge, may it be the cell "wall" or another component in the same
cell. If we use the first example this is how it would be:

panel.add(comp1)
panel.add(comp2, "gapleft 30")

© 2009 MiG InfoCom AB

Advertising