Note! Italics is used to denote an
argument. Square brackets are used to indicate an optional
argument.
UnitValue A value that
represents a size. Normally it consist of a value (integer or float)
and the unit type (e.g. "mm"
). MigLayout
support defining custom unit types and there are some special ones
built in. These are listed below and some have a context to which
they can appear. UnitValues can be quite rich expressions, like:
"(10px + 0.25*((pref/2)-10))"
.
The currently supported unit types are:
"" - No
unit specified. This is the default unit and pixels will be used by
default. Default unit can be set with
PlatformDefaults.setDefaultHorizontal/VerticalUnit(int)
. E.g. "10"
px - Pixels.
Normal pixels mapped directly to the screen. E.g. "10px"
or "10"
% - A percentage
of the container's size. May also be used for alignments where for
instance 50%
means "centered". E.g. "100%"
lp - Logical
Pixels. If the normal font is used on the platform this maps 1:1 to
pixels. If larger fonts are used the logical pixels gets
proportionally larger. Used instead of Dialog Units. E.g. "10lp"
pt - Points.
1/72:th of an inch. A unit normally used for printing. Will take the
screen DPI that the component is showing on into account. E.g.
"10pt"
mm - Millimeters.
Will take the screen DPI that the component is showing on into
account. E.g. "10mm"
cm - Centimeters.
Will take the screen that the component is showing on DPI into
account. E.g. "10cm"
in - Inches. Will
take the screen DPI that the component is showing on into account.
E.g. "10.4in"
sp - Percentage
of the screen. Will take the pixel screen size that the component is
showing on into account. 100.0
is the right/bottom edge
of the screen. E.g. "sp 70" or "sp 73.627123"
al - Visual
bounds alignment. "0al"
is left aligned,
"0.5al"
is centered and "1al"
is right aligned. This unit is used with absolute positioning. E.g.
"0.2al"
n/null - Null value. Denotes the absence of
a value. E.g. "n" or "null"
These are the unit values that are converted to pixels by the
default PlatformConverter
. The converted pixel sizes can
be different for the vertical and horizontal dimension.
r/rel/related -
Indicates that two components or columns/rows are considered
related. The exact pixel size is determined by the platform default.
E.g. "r" or "related"
u/unrel/unrelatedated
- Indicates that two components or columns/rows are considered
unrelated. The exact pixel size is determined by
the platform default. E.g. "u" or "unrelated"
p/para/paragraph
- A spacing that is considered appropriate for a paragraph is used.
The exact pixel size is determined by the platform default. E.g.
"para" or "paragraph"
i/ind/indent - A spacing that is considered
appropriate for indent. The exact pixel size is determined by the
platform default. E.g. "i" or "indent"
These are the unit values that can be specified as a reference to component(s) sizes. These can be used on column/row constraint's size and as a reference in component constaint expressions.
min/minimum - A
reference to the largest minimum size of the
column/row. E.g. "min" or "minimum"
p/pref/preferred
- A reference to the largest preferred size of the
column/row. E.g. "p" or "pref" or
"preferred"
max/maximum - A reference to the smallest
maximum size of the column/row. E.g. "max" or
"maximum"
These are the unit values that can be specified for a component's width. These can only be used on the width component constraints size.
button - A reference to the platform minimum
size for a button. E.g. "wmin button"
BoundSize A bound size is a size that optionally
has a lower and/or upper bound and consists of one to three Unit
Values. Practically it is a minimum/preferred/maximum size
combination but none of the sizes are actually mandatory. If a size
is missing (e.g. the preferred) it is null and will
be replaced by the most appropriate value. For components this value
is the corresponding size (E.g. Component.getPreferredSize()
on Swing) and for columns/rows it is the size of the components in
the row (see min/pref/max
in UnitValue above).
The format is "
min
:
preferred
:
max
"
,
however there are shorter versions since for instance it is seldom
needed to specify the maximum size.
A single value (E.g. "10"
) sets only the
preferred
size and is exactly the same as
"null:10:null"
and ":10:"
and "n:10:n"
.
Two values (E.g. "10:20"
)
means minimum and preferred size and is exactly the same as
"10:20:null"
and "10:20:"
and "10:20:n"
The use a of an exclamation
mark (E.g. "20!"
) means that the value should
be used for all size types and no colon may then be used in the
string. It is the same as "20:20:20"
.
push can be appended to a gap to make that gap
"greedy" and take any left over space. This means that a
gap that has "push"
will be pushing the
components/rows/columns apart, taking as much space as possible for
the gap. The gap push is always an addition to a BoundSize.
E.g. "gap rel:push"
, "[][]push[][]"
,
"10cm!:push"
or "10:10:10:push"
.
Note! For row/column constraints the minimum,
preferred and maximum keywords can
be used and they refer to the largest minimum, preferred and maximum
component in the column/row. A null
value is the same
thing as any of these constraints, for the indicated position, but
they can for instance be used to set the minimum size to the
preferred one or the other way around. E.g. "pref:pref"
or "min:min:pref"
.
AlignKeyword
For alignment purposes these
keywords can be used: t/top, l/left,
b/bottom, r/right, lead/leading,
trail/trailing and base/baseline.
Leading/trailing is dependant on if component orientation is
"left-to-right" or "right-to-left". There is also
a keyword "align label"
or for columns/rows
one need only to use "label".
It will align
the component(s), which is normally labels, left, center or right
depending on the style guides for the platform. This currently means
left justfied on all platforms except OS X which has right justified
labels.
Layout constraings and normally set in
the constructor of MigLayout and is constraints that will affect the
whole container.
|
Sets auto-wrap mode for the layout. This means that the grid
will wrap to a new column/row after a certain number of columns
(for horizontal flow) or rows (for vertical flow). The number is
either specified as an integer after the keyword or if not, the
number of column/row constraints specified will be used. A
wrapping layout means that after the |
|
|
Specifies the default gap between the cells in the grid and are thus overriding the platform default value. The gaps are specified as a BoundSize. See above. |
|
|
Turns on debug painting for the container. This will lead to an
active repaint every |
|
|
Puts the layout in a flow-only mode. All components in the flow direction will be put in the same cell and will thus not be aligned with component in other rows/columns. For normal horizontal flow this is the same as to say that all component will be put in the first and only column. |
|
|
Turns off padding of visual bounds (e.g. compensation for drop shadows) |
|
|
Claims all available space in the container for the columns and/or rows. At least one component need to have a |
" |
|
Specified the insets for the laid out container. The gaps
before/after the first/last column/row overrides these layout
insets. This is the same thing as setting an |
|
|
Puts the layout in vertical flow mode. This means that the next cell is normally below and the next component will be put there instead of to the right. Default is horizontal flow. |
|
|
Specifies the alignment for the laid out components as a group.
If the total bounds of all laid out components does not fill the
entire container the align value is used to position the
components within the container without changing their relative
positions. The alignment can be specified as a UnitValue
or AlignKeyword. See above. If an AlignKeyword
is used the |
|
|
Overrides the container's |
|
|
Specifies if the components should be added in the grid bottom-to-top or top-to-bottom. This value is not picked up from the container and is top-to-bottom by default. |
|
|
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: |
|
|
Instructs the layout engine to not use caches. This should
normally only be needed if the |
|
Column and row constraints works the same and hence forth the term row will be used for both columns and rows.
Every [] section denotes constraints for that row. The gap size
between is the gap size dividing the two rows. The format for the
constraint is:[constraint1, constraint2, ...]gap
size[constraint1, constraint2, ...]gap size[...]..."
Example:
"[fill]10[top,10:20]"
, "[fill]push[]"
,
"[fill]10:10:100:push[top,10:20]"
.
Tip! A vertical bar "|"
can be used instead of "]["
between rows if
the default gap should be used. E.g. "[100|200|300]"
is the same as "[100][200][300]"
.
Gaps are expressed as a BoundSize (see above) and
can thus have a min/preferred/max size. The size of the row is
expressed the same way, as a BoundSize. Leaving any
of the sizes out will make the size the default one. For gaps this is
"related"
(the pixel size for "related"
is determined by the PlatformConverter
) and for row size
this is the largest of the contained components for minimum and
preferred size and no maximum size. If there are fewer rows in the
format string than there are in the grid cells in that dimension the
last gap and row constraint will be used for the extra rows. For
instance "[10]"
is the same as "[10][10][10]"
(affects wrapping if wrap is turned on though) .
Gaps have only their size, however there are number of constraints
that can be used between the [ ]
and they will affect
that row.
":push"
(or "push"
if used with the default gap size) can be added to the gap size to
make that gap greedy and try to take as much space as possible
without making the layout bigger than the container.
Note! ""
is the same as
"[]"
which is the same as "[pref]"
and "[min:pref:n]"
.
|
Gives the row a size group name. All rows that share a size
group name will get the same BoundSize as the row
with the largest min/preferred size. This is most usable when the
size of the row is not explicitly set and thus is determined by
the largest component is the row(s). An empty name |
|
|
Set the default value for components to |
|
|
Puts the row in flow-only mode. All components in the flow
direction will be put in the same cell and will thus not be
aligned with component in other rows/columns. This property will
only be adhered to if the row is in the flow direction. So for the
normal horizontal flow ( |
|
|
Sets how keen the row should be to grow in relation to other
rows. The weight (defaults to 100 if not specified) is purely a
relative value to other rows' weight. Twice the weight will get
double the extra space. If this constraint is not set, the grow
weight is set to zero and the column will not grow (unless |
|
|
Sets the grow priority for the row (not for the components in the row). When growing, all rows with higher priorities will be grown to their maximum size before any row with lower priority are considered. The default grow priority is 100. This can be used to make certain rows grow to max before other rows even start to grow. |
|
|
Sets how keen/reluctant the row should be to shrink in relation to other rows. The weight is purely a relative value to other rows' weights. Twice the weight will shrink twice as much when space is scarce. If this constraint is not set the shrink weight defaults to 100, which means that all rows by default can shrink to their minimum size, but no less. Shrink weight will only be compared against the weights in the same shrink priority group (other rows with the same shrink priority). See below. |
|
|
Sets the shrink priority for the row (not for the components in the row). When space is scarce and rows needs to be shrunk, all rows with higher priorities will be shrunk to their minimum size before any row with lower priority are considered. The default shrink priority is 100. This can be used to make certain rows shrink to min before other rows even start to shrink. |
|
|
Specifies the default alignment for the components in the row.
This default alignment can be overridden by setting the alignment
for the component in the Component Constraint. The default row
alignment is |
|
|
Specifies the gap before and/or after the row. The gap are
specified between the row constraints (between |
|
Component constraints are used as an argument in the
Container.add(...)
for Swing and by setting it as
Control.setLayoutData(...)
in SWT. It can be used to
specify constraints that has to do with the component's size and/or
the grid cell flow. The constraints are specified one by one with
comma signs as separators. E.g. "width 100px!, grid 3
2, wrap"
.
|
Wraps to a new column/row after the component
has been put in the next available cell. This means that the next
component will be put on the new row/column. Tip! Read wrap as
"wrap after". If specified |
|
|
Wraps to a new column/row before the component
is put in the next available cell. This means that the this
component will be put on a new row/column. Tip! Read wrap as "on
a newline". If specified |
|
|
Makes the row and/or column that the component is residing in
grow with |
|
|
Skips a number of cells in the flow. This is used to jump over
a number of cells before the next free cell is looked for. The
skipping is done before this component is put in a cell and thus
this cells is affected by it. |
|
|
Spans the current cell (merges) over a number of cells.
Practically this means that this cell and the count
number of cells will be treated as one cell and the component can
use the space that all these cells have. count defaults
to a really high value which practically means span to the end
or the row/column. Note that a cell can be spanned and
split at the same time, so it can for instance be spanning 2 cells
and split that space for three components. |
|
|
Splits the cell in a number of sub cells. Basically this means
that the next |
|
|
Sets the grid cell that the component should be placed in. If
there are already components in the cell they will share the cell.
If there are two integers specified they will be interpreted as
absolute coordinates for the column and row. The flow will
continue after this cell. How many cells that will be spanned is
optional but may be specified. It is the same thing as using the
|
|
|
Sets the flow direction in the cell. By default the flow
direction in the cell is the same as the flow direction for the
layout. So if the components flows from left to right they will do
so for in-cell flow as well. The first component added to a cell
can change the cell flow. If flow direction is changed to |
|
|
Overrides the default size of the component that is set by the
UI delegate or by the developer explicitly on the component. The
size is specified as a BoundSize. See the Common
Argument Types section above for an explanation. Note that
expressions is supported and you can for instance set the size for
a component with |
" |
|
Overrides the default size of the component for minimum or
maximum size that is set by the UI delegate or by the developer
explicitly on the component. The size is specified as a BoundSize.
See the Common Argument Types section above for an
explanation. Note that expressions is supported and you can for
instance set the size for a component with |
" |
|
Sets how keen the component should be to grow in relation to
other component in the same cell. The weight (defaults to 100 if
not specified) is purely a relative value to other components'
weight. Twice the weight will get double the extra space. If this
constraint is not set the grow weight is set to 0 and the
component will not grow (unless |
|
|
Sets the grow priority for the component. When growing, all components with higher priorities will be grown to their maximum size before any component with lower priority are considered. The default grow priority is 100. This constraint can be used to make certain components grow to max before other components even start to grow. |
|
|
Sets how keen/reluctant the component should be to shrink in relation to other components. The weight is purely a relative value to other components' weight. Twice the weight will shrink twice as much when space is scarce. If this constraint is not set the shrink weight defaults to 100, which means that all components by default can shrink to their minimum size, but no less. Shrink weight will only be compared against the weights in the same shrink priority group (other components with the same shrink priority). See below. |
|
|
Sets the shrink priority for the component. When space is scarce and components needs be be shrunk, all components with higher priorities will be shrunk to their minimum size before any component with lower priority are considered. The default shrink priority is 100. This can be used to make certain components shrink to min before other even start to shrink. |
|
|
Gives the component a size group name. All components that
share a size group name will get the same BoundSize
(min/preferred/max). It is used to make sure that all components
in the same size group gets the same min/preferred/max size which
is that of the largest component in the group. An empty name |
|
|
Gives the component an end group name and association. All
components that share an end group name will get their
right/bottom component side aligned. The right/bottom side will be
that of the largest component in the group. If |
|
|
Specifies the gap between the components in the cell or to the
cell edge depending on what is around this component. If a gap
size is missing it is interpreted as |
|
|
Specifies the horizontal or vertical gap between the components
in the cell or to the cell edge depending on what is around this
component. If a gap size is missing it is interpreted as |
|
|
Sets the id (or name) for the component. If the |
|
|
Positions the component with absolute coordinates relative to
the container. If this keyword is used the component will not
be put in a grid cell and will thus not affect the flow in the
grid. One of either Absolute positions can also links to other components' bounds
using their
|
|
|
Used to position the start (x or y), end (x2 or y2) or both edges of a component in absolute coordinates. This is used for when a component is in a grid or dock and it for instance needs to be adjusted to align with something else or in some other way be positioned absolutely. The cell that the component is positioned in will not change size, neither will the grid. The x, y, x2 and y2 keywords are applied in the last stage and will therefore not affect other components in the grid or dock, unless they are explicitly linked to the bounds of the component. If the position and size can be determined without references to the parent containers size it will affect the preferred size of the container. |
|
|
Used for docking the component at an edge, or the center, of the container. Works much like |
|
|
Sets the padding for the component in absolute pixels. This is
an absolute adjustment of the bounds if the component and is done
at the last stage in the layout process. This means it will not
affect gaps or cell size or move other components. It can be used
to compensate for something that for some reason is hard to do
with the other constraints. For instance |
|
|
Specifies the alignment for the component if the cell is larger
than the component plus its gaps. The alignment can be specified
as a UnitValue or AlignKeyword.
See above. If AlignKeyword is used the |
|
|
Inhibits MigLayout to change the bounds for the component. The
bounds should be handled/set from code outside this layout manager
by calling the |
|
|
Sets the hide mode for the component. If the hide mode has been
specified in the 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: |
|
|
Tags the component with metadata name that can be used by the
layout engine. The tag can be used to explain for the layout
manager what the components is showing, such as an OK
or Cancel button. Unknown tags will be
disregarded without error or any indication.
|
|