windowing capabilities since its earliest days. The first version
made public was the
Toolkit, or AWT. AWT used the native toolkit components, so it was
relatively small and simple. AWT suffered somewhat from being a
“least common denominator”; a feature could not be added
unless it could be implemented on all major platforms that Java
supported. The second major implementation was the
released in 1998 as part of the Java Foundation Classes. Swing is a
full-function, professional-quality GUI toolkit designed to enable
almost any kind of client-side GUI-based interaction. AWT lives on
inside, or rather underneath, Swing, and for this reason many
programs begin by importing both
This chapter presents a few elements of Java windowing for the developer whose main exposure to Java has been on the server side. The examples are shown using Swing, rather than the obsolescent AWT components. For a slightly more detailed presentation, the reader is referred to Learning Java. For a very thorough presentation on all aspects of Swing, I recommend the O’Reilly book Java Swing, by Robert Eckstein, Marc Loy, and Dave Wood. At 1252 pages it’s not an overnight read. But it is comprehensive.
Java’s event model has evolved over time, too. In JDK 1.0, the writer of a windowed application had to write a single large event-handling method to deal with button presses from all the ...