12.19 Using Panels to Manage More Complex Layouts
Complex GUIs (like Fig. 12.1) often require that each component be placed in an exact location. They often consist of multiple panels, with each panel’s components arranged in a specific layout. Class JPanel
extends JComponent
and JComponent
extends class Container
, so every JPanel
is a Container
. Thus, every JPanel
may have components, including other panels, attached to it with Container
method add
. The application of Figs. 12.45–12.46 demonstrates how a JPanel
can be used to create a more complex layout in which several JButton
s are placed in the SOUTH
region of a BorderLayout
.
Get Java™ How To Program (Early Objects), Tenth 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.