Chapter 13: Graphical User Interface Controls
Note: this page applies to the now-obsolete first edition of the book. For
the second edition, please see
http://www.corewebprogramming.com.
This chapter of
Core Web Programming (pages 640-747) covers all of the 1.1 AWT GUI
controls not previously classified as "windows" and discussed in
Chapter 11. For each, it
explains the constructors, general usage, additional methods, and
event-handling approaches.
Note that the entire text of this chapter is
available on-line. Also note that on-line examples that
say they require Java 1.1 means that you need IE4 or Netscape 4.06 or
later. IE3, Netscape3, and Netscape 4.0-4.05 do not support
Java 1.1.
Contents
Note that several of these require Java 1.1. The ones that are
designed to work with both 1.0 and 1.1 (ie to support Netscape 4.05
and earlier) might give warnings about "deprecated APIs" when compiled
on a Java 1.1 system. You can ignore these warnings.
-
ActionExample1.java. This illustrates processing action
events in individual components in Java 1.0. Requires
ResizeButton and
QuittableFrame.
-
ResizeButton.java. A button, that when clicked, resizes the
window that contains it. Used in ActionExample1.
-
ActionExample2.java. This illustrates processing action
events in containers in Java 1.0. Requires
QuittableFrame.
- ActionExample3.java.
This illustrates processing action
events in individual components in Java 1.1. Requires
SetSizeButton and
CloseableFrame.
-
SetSizeButton.java
-
ActionExample4.java. This illustrates processing action
events in external listeners in Java 1.1. Requires
CloseableFrame.
-
Buttons.java. Shows some simple buttons.
(also available on-line through
Buttons.html)
-
ButtonExample.java. Illustrates the processing of button
events in Java 1.1. Requires
FgReporter,
BgReporter,
SizeReporter, and
CloseableFrame.
-
FgReporter.java
-
BgReporter.java
-
SizeReporter.java
-
ImageLabel/ImageButtons.java. Illustrates some image
buttons. Requires
ImageButton
(also available on-line through
ImageLabel/ImageButtons.html)
-
ImageLabel/ImageButton.java. A class that acts like Button
(in Java 1.0) but supports images instead of text.
-
Checkboxes.java. Shows some simple checkboxes.
Requires
QuittableFrame.
-
CheckboxGroups.java. Shows regular checkboxes next to
radio buttons (checkboxes in groups).
(also available on-line through
CheckboxGroups.html)
-
SimpleChoiceTest.java. Shows a simple choice list (drop-down
menu).
(also available on-line through
SimpleChoiceTest.html)
-
ChoiceTest.java. Adds some basic Java 1.0-style event
processing to the SimpleChoiceTest.
(also available on-line through
ChoiceTest.html)
-
Lists.java. A simple list box (Java 1.02 syntax). Requires
QuittableFrame.
-
TwoLists.java. Pure 1.1 version of a simple list box. Requires
CloseableFrame.
-
ListEvents1.java. Illustrates the handling of list events in
Java 1.0. Requires
QuittableFrame.
-
ListEvents2.java. Illustrates the handling of list events in
Java 1.1. Requires
SelectionReporter,
ActionReporter, and
CloseableFrame.
-
SelectionReporter.java
-
ActionReporter.java
-
ListEvents3.java. Extends ListEvents2 to handle more events,
and illustrates inner classes.
-
TextFields.java. Shows some basic textfields.
(also available on-line through
TextFields.html)
-
JavaTextField.java. Illustrates textfield event-handling
in Java 1.0 by making a spelling-correcting textfield.
(also available on-line through
JavaTextField.html)
-
JavaTextField2.java. Illustrates textfield event-handling
in Java 1.1 by making a spelling-correcting textfield.
Requires
LanguageField
(also available on-line
in a Java 1.1 capable browser
through
JavaTextField2.html)
-
LanguageField.java
-
TextAreas.java. Shows two simple text areas.
(also available on-line through
TextAreas.html)
-
Labels.java. Shows some simple text labels.
(also available on-line through
Labels.html)
-
ReverseLabels.java. Shows how to handle mouse events for
labels in Java 1.1. Requires
ReversibleLabel and
CloseableFrame.
-
ReversibleLabel.java. Uses inner classes to process
mouse-enter and mouse-exit events.
-
ScrollbarValues.java. Illustrates the difference between
how Java 1.0 and 1.1 interpret maximum values in scrollbars.
Requires QuittableFrame.
-
WastedSpace.java. Illustrates an implementation bug whereby
Internet Explorer 3, Netscape 4, and Sun's 1.02 JDK leave
wasted space at the bottom/right of scrollbars with small
ranges of values on Windows 95/NT.
(also available on-line through
WastedSpace.html)
-
Scrollbars.java. Scrollbars with varying bubble (thumb)
sizes but constant ranges and initial values.
(also available on-line through
Scrollbars.html)
-
BetterScrollbar.java. A scrollbar class that interprets
maximum values identically in Java 1.0 and 1.1, and tries to
work around the inconsistent support for unit/block scroll
settings.
-
Sliders.java. Illustrates a slider class that encapsulates
a textfield and a scrollbar. Requires
Slider,
ScrollbarPanel,
and QuittableFrame.
(You can also view an applet version of this on-line at
SliderApplet.html.)
-
Slider.java. A slider class that encapsulates
a textfield and a scrollbar. Documentation is on-line at
Slider.html, with an example at
SliderApplet.html.
Requires
ScrollbarPanel
and QuittableFrame.
-
ScrollbarPanel.java
-
ColorPopupMenu.java. Illustrates popup menus in Java 1.1.
(also available on-line
in a Java 1.1 capable browser
through
ColorPopupMenu.html)
- JAppletExample.java.
Illustrates the three major differences between using JApplet
and Applet:
- Using the content pane,
- Getting Java (Metal) look and feel by default, and
- Having BorderLayout be the default instead of FlowLayout.
Requires WindowUtilities;
run it by loading
JAppletExample.html
in appletviewer in Java2 (or in a regular browser only
if you have installed Swing 1.1).
- JFrameExample.java.
Illustrates two major differences between using JFrame
and Frame:
- Using the content pane,
- Getting Java (Metal) look and feel by default
Requires WindowUtilities
and ExitListener.
You need Java2 or Swing 1.1 to run this.
- JOptionPaneExamples.java.
This demonstrates the use of the Swing JOptionPane methods,
letting the user interactively create any of the main JOptionPanes,
specifying the various options and choosing the desired looks.
Requires Swing 1.1 or Java2 (JDK 1.2), as well as using
WindowUtilities,
ExitListener,
DisableListener,
JLabeledTextField, and
RadioButtonPanel.
These are panels that incorporate a control and
a label, a commonly desired feature. Several of
these are used in later chapters.