When set the layout manage with a GridLayout
, you can specify the gaps between elements:
setLayout(new GridLayout(rows, cols, hgap, vgap));
hgap
> the gap size between elements horizontally
vgap
> the gap size between elements vertically
Java doc:
In addition, the horizontal and vertical gaps are set to the specified values. Horizontal gaps are placed between each of the columns. Vertical gaps are placed between each of the rows.