GridLayout
places components in a grid of cells that are in rows and columns. GridLayout
expands each component to fill the available space within its cell. Each cell is exactly the same size and the grid is uniform. When you resize a GridLayout
container, GridLayout
changes the cell size so the cells are as large as possible, given the space available to the container.
Example
Use GridLayout
if you are designing a container where you want the components to be of equal size, for example, a number pad or a toolbar.
GridLayout
is that one of the rows or columns (not both) can be zero. You must have a value in at least one so the GridLayout
manager can calculate the other.
For example, if you specify four columns and zero rows for a grid that has 15 components, GridLayout
creates four columns of four rows, with the last row containing three components. Or, if you specify three rows and zero columns, GridLayout
creates three rows with five full columns.
hgap
) and vertical gap (vgap
). The default horizontal and vertical gap is zero.
To change the property values for a GridLayout
container using the visual design tools, select the GridLayout
object displayed below the container it controls in the component tree, then edit the values for the rows
, cols
, hgap
, or vgap
in the Inspector.