Java Reference
In-Depth Information
Figure 12.5 This figure provides the Metal look and feel of the PLAFDemo program
(top), Motif look and feel of the PLAFDemo program (center), and Windows look and feel
of the PLAFDemo program (bottom).
You can resize the Frame from FlowLayoutDemo, and the components will
adjust their location so they remain centered in the window. If the Frame is not
wide enough to display all the components, the components will wrap around
to a new line.
BorderLayout Manager
The java.awt.BorderLayout class represents a BorderLayout manager, which
divides a container into five different regions: north, south, east, west, and cen-
ter. Only one component can be added to a given region, and the size of the
component is determined by the region it appears in. BorderLayout has the
following properties:
When a component is added, you pass in an int to the add() method
that denotes the region of the container in which the component is to
be added. The possible values are NORTH, SOUTH, EAST, WEST, and
CENTER, which are all static fields in the BorderLayout class.
■■
You do not need to add a component to each region. If a region is left
empty, the area is filled with the other components in the neighboring
regions.
■■
A component added to the north or south gets its preferred height, but
its width will be the width of the container.
■■
Search WWH ::




Custom Search