GridLayout

The GridLayout layout manager is ideal for laying out objects in rows and columns, where each cell in the layout has the same size. Components are added to the layout from left to right, top to bottom. setLayout(new GridLayout(2,3)) changes the LayoutManager of the current container to a 2 row by 3 column GridLayout. Figure 7.6 shows an applet using this layout.

Figure 7.6: Applet using GridLayout

[Graphic: Figure 7-6]

GridLayout Methods

Constructors

NOTE:

The rows and columns passed to the GridLayout constructor are only recommended values. It is possible that the system will pick other values if the number of objects you add to the layout is sufficiently different from the size you requested; for example, you placed nine objects in a six-element grid.

Informational methods LayoutManager methods Miscellaneous methods
java.awt.GridLayout[hgap=0,vgap=0,rows=2,cols=3]