The Java GridLayout class is used to arrange the components in a rectangular grid. One component is displayed in each rectangle.
The GridLayout() constructor creates only one row. The following example shows the usage of the parameterless constructor.
FileName: GridLayoutExample.java
Output:

FileName: MyGridLayout.java
Output:

The following example inserts horizontal and vertical gaps between buttons using the parameterized constructor GridLayout(int rows, int columns, int hgap, int vgap).
FileName: GridLayoutExample1.java
Output:

We request you to subscribe our newsletter for upcoming updates.