The grid layout manager places components in a grid of cells. Each component takes all the available space within its cell, and each cell is exactly the same size.


This layout manager is used rarely.

GridLayout is part of the standard Java distribution. The API documentation is available here.

Layout manager properties

A container with this layout manager has following layout manager properties:

Property Name Description Default
columns The number of columns. Zero means any number of columns.
rows The number of rows. Zero means any number of rows.
Note: If the number of rows is non-zero, the number of columns specified is ignored. Instead, the number of columns is determined from the specified number or rows and the total number of components in the layout.
horizontal gap The horizontal gap between components. 0
vertical gap The vertical gap between components. 0