Some times we need to create GUI that have a matrix-type layout with columns of same widths and rows of same heights. For this purpose, the layout manager "GridLayout" class, defined in "java.awt" package, is used that lays out components in different equally sized rectangular cells.
You can set number of columns and number of rows by it's constructor GridLayout(int rows, int cols) or by methods setRows() and setColumns(). You can also set horizontal and vertical gaps with its constructor GridLayout(int rows, int cols, int hgap, int vgap) or by methods setHgap(int hgap) and setVgap(int vgap).
Read more at:
Liked it! Share this Tutorial