Chapter 13. Graphical User Interfaces
Introduction
Java has
had
windowing capabilities since its earliest days. The first version
made public was the
Abstract Windowing
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
Swing classes,
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 java.awt
and
javax.swing
.
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 ...
Get Java Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.