The AWT is the part of the Java environment that contains the set of classes for writing GUI (Graphic User Interface) Graphic programs:
The Basic Controls: Buttons, Checkboxes, Choices, Lists, Menus, and Text Fields
When a user activates one of these controls, it posts an Action event to be handled by the object that contains the control.
Other Ways of Getting User Input: Sliders, Scrollbars, and Text Areas
The Scrollbar class is used for both slider and scrollbar functionality. The TextArea class simply provides an area to display or edit text.
Creating Custom Components: Canvases
With your Canvas subclass, you can draw custom graphics to the screen and implement any kind of event handling.
Labels
A Label simply displays an unselectable line of text.
Containers: Windows and Panels
The Window subclasses provide windows to contain components. Panels group components within an area of an existing window.
The Converter class actually extends the Applet class (which itself extends Panel), instead of directly extending Panel.
The ConversionPanel class provides a way of grouping all the controls that describe a particular set of distance measurements.
The Unit class provides objects that group a description (such as "Centimeters") with a multiplier that indicates the number of units per meter (0.01, for example).
Frame
|
...
|
Converter
|
----------------------------------
| |
ConversionPanel (metricPanel) ConversionPanel (usaPanel)
| |
------------------- -------------------
| | | | | |
Label | Choice Label | Choice
| |
-------------- --------------
| | | |
TextField Scrollbar TextField Scrollbar
When the Converter application draws itself, here's what happens
The Frame draws itself.
The Converter object draws itself, drawing a box around its area.
One of the two ConversionPanels draws itself, drawing a box around its area.
The contents of the ConversionPanel -- the Label, TextField, Scrollbar, and Choice -- draw themselves.
How Drawing Requests are handled
AWT ----> Component's update() ----> Component's paint()
Paint method
public void paint(Graphics g) { Dimension d = size(); g.drawRect(0,0, d.width - 1, d.height - 1); }
Copyright © 1998-2009 Dilvan Moreira