12.3. The GridLayout Manager

The GridLayout manager divides the window into equal-sized rectangles based upon the number of rows and columns specified. Items are placed into the cells left to right, top to bottom, based upon the order in which they are added. Each component is resized to fit into its grid cell without regard to its current or preferred size. A constructor option lets you specify the gaps between the rows and columns.

Listing 12.3 presents an applet divided into two rows and three columns, with a button placed into each cell. Figure 12-3 shows the result.

Figure 12-3. GridLayout divides the window into equal-sized rectangles.

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.