Day 4 Overview
July 9, 1997
Any Questions?
Brief Review
More Examples of Using the Package awt
(awt = Abstract Windowing
Toolkit) for creating GUIs
- Example 1: Using canvases to make custom components -- traffic lights.
- Example 1.1: A changeable traffic light.
- Example 2: Thermometers.
- Layout managers
- BorderLayout -- the default mgr for the classes Window, Dialog,
and Frame
- FlowLayout -- the default for Panel and Applet classes
- GridLayout -- creates a rectangular grid of components of
uniform size
- GridBagLayout -- also divides the container into a grid but in
a much more flexible way than GridLayout
- CardLayout -- like a deck of cards with only the top component
visible
Related material from the textbooks
- The Java 1.1 Developer's Handbook, chapter on "Creating
Custom Components" (first part),
pp. 41-70 is relevant to examples 1, 1.1, and 2.
There is a nice section on event handling, pp. 45-50. Note,
however, that this chapter (as well as our examples) still use
the event handling mechanisms of JDK 1.0.
- Developer's Handbook, Chapter 4, "Layout Managers,"
pp. 106-181 but especially pages 106-131. This is the best
description of layout managers and their use that I have
seen.
- Late Night Advanced Java, chapter 6.
Corrected programs for most of the examples can be found in
chapter 6: corrected examples.