What is the difference between these two constraints?
From documentation:
PUSH - makes the row and/or column that the component is residing in grow with "weight"
GROW - Sets how keen the component should be to grow in relation to other component in the same cell.
So, the main idea is to shrink size inside and outside of component?
It is important to understand that
fill
, (column, row)grow
,push
work in conjunction with the (component)grow
to define the layout. (There are two differentgrow
constraints that do different things.)MigLayout
is a grid-based manager. (More precisely, its most important mode is.) There are two steps that need to be done:This is what
fill
, (column, row)grow
,push
and (component)grow
constraints help achieve. The first three define the growth of the grid's columns and rows, the last one defines how the component will spread over its alotted area, e.g. cell(s) that it is placed in. Note that filling or growing is the tendency or eagerness to occupy empty space in the layout. The window area that is not taken by columns, rows, or components is filled with empty space.The
push
and the (column, row)grow
take optionalweight
parameter. It defines how keen the column or row should grow in relation to other columns and rows. Thefill
constraint distributes theweight
evenly.(The
push
constraint may be used to make gaps greedy in different context.)I provide three examples that clarify usage of these constraints.
Fill
The
fill
constraint affects all cells of the grid. They occupy all available space. The (component)grow
constraint specifies how the components spread in their cells.In the example we have three labels.
The
fill
is a layout constraint; it affects all cells.Now we define how the components fill their areas alotted by the layout manager. The Area 1 label fills its alotted area horizontally, the other two labels fill the alotted area in both dimensions.
Column, row grow
The (column, row)
grow
constraint affects all cells in particular column or row.In the example we have two components. The text field is expected to grow horizontally, the text area both horizontally and vertically.
In this line we specify that the first colum and the second row of the grid grow.
Now we define that the text field fills its alotted area horizontally while the text area fills the whole alotted area.
Push
The
push
constraint is esentially the same as the (column, row)grow
. The difference is thatpush
is specified at theadd()
method.The example is the same as the previous one.
No growing is specified here.
Everything is specified using components' constraints within the
add()
methods.