Component sizes, Row and column sizes, Panel insets – MiG InfoCom MiG Layout Quick Start Guide User Manual

Page 4

Advertising
background image

panel.add(comp3, "wrap") // Wrap to next row
panel.add(comp4)

comp1

comp2

comp3

comp4

There are many gap constraints, for instance

"gapbefore"

and

"gaptop"

. You can read about them in

the Cheat Sheet or White Paper on www.migcomponents.com.

Component Sizes

Components have sizes provided by the GUI framework in some way. Swing even has support for
minimum/preferred/maximum size while SWT only has a preferred size. You can override these sizes and for
SWT even extend the functionality by providing the sizes in the constraints. The sizes are specified in the
form:

"min:preferred:max"

(E.g.

"10:20:40"

). A size not specified will default to the component's

corresponding size (E.g.

"10::40"

will set the min and max size but preserve the original preferred size).

There are a lot of short ways to set the sizes, for instance

"40!"

means that all three sizes will be set to 40.

Examples:

panel.add(comp, "width 10:20:40");

panel.add(comp, "height ::40"); // Same as "hmax 40".

panel.add(comp, "w 40!"); // w is short for width.

Row and Column sizes

Rows and columns default to the size of the largest component in the column/row. This can be overridden
and it works exactly the same ways as the component sizes above. You specify the column/row size in the
corresponding constraint, normally when creating the layout manager. Here are some examples:

MigLayout layout = new MigLayout(
"", // Layout Constraints
"[10][20:30:40][40!][::40]", // Column constraints
"[min!][10::20][40mm!]"); // Row constraints

Did you see the

"min!"

part? "min", "pref", "max" can be used on both component and column/row

sizes to refer to the original size. So "min!" means that minimum, preferred and maximum size will all be
set to the minimum size of the row, ensuring the row will for sure get its minimum size.

Panel Insets

By default there will be an invisible border around the layout, except if you have docking components. The
size of it is different on different platforms. Sometimes this is not what you want or you just want to specify
another inset. You can change this in the layout constraint. Examples:

© 2009 MiG InfoCom AB

Advertising