Java Reference
In-Depth Information
Layout managers learn about a component's/container's preferred, maximum, and
minimum sizes by calling Component 's Dimension getPreferredSize() ,
Dimension getMaximumSize() , and Dimension getMinimumSize()
was not introduced [via LayoutManager2 ] until JDK 1.1.)
Note The java.awt.Dimension class declares public width and height
fields(oftype int )thatcontainthecomponent'swidthandheight.Althoughdirectly
feltthatitwasmoreperformanttoaccessthesefieldsdirectly.Furthermore, Dimen-
sion is one class that will probably never change.
Each container has a default layout manager. For example, Frame 's default layout
manageris BorderLayout ,whereas Panel 'sdefaultlayoutmanageris FlowLay-
out . You can replace this default by calling Container 's void setLay-
out(LayoutManager mgr) methodtoinstallyourownlayoutmanager,asdemon-
strated here:
Panel pnl = new Panel();
pnl.setLayout(new GridLayout(3, 2));
The first line creates a Panel that defaults to FlowLayout . The second line re-
placesthislayoutmanagerwitha GridLayout thatlaysoutamaximumofsixcom-
ponents in a three-row-by-two-column grid.
Events Overview
GUIinteractions.Eachinteractionisknownasan event ,andisdescribedbyaconcrete
java.awt.event subclass of the abstract java.awt.AWTEvent class.
AWTEvent is subclassed by several event classes: ActionEvent , Adjust-
mentEvent , AncestorEvent , ComponentEvent , HierarchyEvent , In-
putMethodEvent ,
InternalFrameEvent ,
InvocationEvent ,
ItemEvent , and TextEvent .
ComponentEvent isthesuperclassfor ContainerEvent , FocusEvent , In-
putEvent , PaintEvent ,and WindowEvent . InputEvent istheabstractsuper-
class for KeyEvent , which is subclassed by MenuKeyEvent , and MouseEvent ,
which is subclassed by MenuDragMouseEvent and MouseWheelEvent .
Search WWH ::

Custom Search