|Widgets (Components) Example Code
Components (also known as widgets) are the various user controls and displays provided by the Java AWT; they are the basic building blocks of a Graphical User Interface. The following illustration shows the most common AWT components:
Each of the components in the above Applet, when manipulated,
places a message in the status line of the applet (in the above illustration,
the status line contains the text
Applet started.) The status line
is visible when you run the applet with
appletviewer, but is usually
not shown by browsers.
The code for this applet illustrates:
There are two versions of the source code for this applet:
Widgets.java uses anonymous inner classes; complete BlueJ package is in WidgetsAnonymous.zip.
Widgets2.java uses member classes; complete BlueJ package is in WidgetsMembers.zip.
In general, member classes are easier to understand, while anonymous inner classes are more convenient.