Using the GridBagLayout Manager

Finally, we saved the most important and the most complicated layout manager for last. GridBagLayout divides the frame into rows and columns as it did with GridLayout. Both GridLayout and GridBagLayout share the same definition of a cell—the intersection of a row and a column. Each component, however, is not restricted to be just the size of one cell, but can span multiple cells (see Figure 12.7). The area in which a component can span multiple cells is called its display area. This difference makes GridBagLayout the most flexible and the most portable of all the layout managers. Even though GridBagLayout is complex, it behaves best if you use a smaller number of nested panels.

Figure 12.7. Using GridBagLayout ...

Get Borland® JBuilder™ Developer’s Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.