Java Reference
In-Depth Information
void windowActivated(WindowEvent
e)
void windowClosed(WindowEvent e)
void windowClosing(WindowEvent e)
void
windowDeactivated(WindowEvent e)
void
windowDeiconified(WindowEvent e)
void windowIconified(WindowEvent
e)
v oid windowOpened(WindowEvent e)
Containers and Layout
As soon as the user interface consists of more than one or two components, the screen layout of the
components becomes an issue. For some devices, it would be possible to place the components at fixed
pixel positions. However, for portable Java applications, this approach isn't really suitable. In addition
to the different screen sizes and layouts, the components might also have different sizes on different
PDAs.
Fortunately, Java provides a powerful mechanism to cope with layout problems: Layout Managers.
Layout Managers can be assigned to subclasses of Container such as Frame , Dialog , or Panel
using the setLayoutManager() method. Layout Managers place the components contained in the
assigned Container with respect to special rules determined by the concrete subclass of
LayoutManager used. For example, GridLayout arranges all contained components in a grid
where each component has exactly the same size. BorderLayout divides the Container into five
regions as shown in Figure 4.2 . The desired region is given as a parameter to the add() method when
adding components to the container. The border region takes the minimum space that is required for
displaying the contained components, and the remainder goes to the center area. The BorderLayout
is the default layout manager of Dialog s and Frame s. The FlowLayout arranges all components
in a horizontal line where the width of the components is minimized and the height is aligned to the
minimal height of the highest component. FlowLayout is the default layout manager of Panel.
Figure 4.2. The five regions of the BorderLayout .
Search WWH ::




Custom Search