
commonly used feature of JRootPane, however, is that it displays a JMenuBar
passed to its setJMenuBar() method. (In AWT, you specify a MenuBar for a Frame
by calling the setMenuBar() method of Frame.)
Layout Management
Some containers, such as JTabbedPane and JSplitPane, define a particular
arrangement for their children. Other containers such as
JPanel (and JFrame, JDi-
alog
, and other top-level containers that use JPanel as their default content pane)
do not define any particular arrangement. When working with containers of this
type, you must specify a
LayoutManager object to arrange the children within the
container.
AWT and Swing include various implementations of the
java.awt.LayoutManager
inter face. Each arranges components in a differ ent way. Table 2-5 lists the layout
managers defined by AWT. Swing applications often rely on these AWT layout
managers, but Swing also defines some of its own, which are listed in Table 2-6.
Figur e 2-2 shows how some of these layout managers arrange their children.
Table 2−5: AWT Layout Managers
Layout Manager Description
BorderLayout Lays out a maximum of five components: one along each of
the four borders of the container and one in the center. When
using this layout manager, you must add components to the
container using a two-argument version of the
add() method.
The constraint argument should be one of the strings “North”,
“East”, “South”, “West”, or “Center”. ...