文档介绍:Part I - Foundations
Part I consists of two chapters that lay the foundation for a essful and productive journey through the JFC Swing
class library. The first begins with a brief overview of what Swing is and an introduction to its architecture. The second
builds up into a detailed discussion of the key mechanisms underlying Swing, and how to interact with them. There are
several sections on topics that are fairly advanced, such as multithreading and painting. This material is central to many
areas of Swing and by introducing it in chapter 2, your understanding of what is e will be significantly enhanced.
We expect that you will want to refer back to this chapter quite often, and in several places we explicitly refer you to it
in the text. At the very least, it is mended that you know what chapter 2 contains before moving on.
Chapter 1. Swing Overview
In this chapter:
• AWT
• Swing
• MVC
• UI delegates and PLAF
AWT (the Abstract Window Toolkit) is the part of Java designed for creating user interfaces and painting graphics and
images. It is a set of classes intended to provide everything a developer requires in order to create a graphical interface
for any Java applet or application. Most ponents are derived from the class as
figure illustrates. (Note that AWT menu bars and menu bar items do not fit within ponent hierarchy.)
Figure 1. ponenthierarchy
<<file figure1->>
The Java Foundation Classes consist of five major parts: AWT, Swing, Accessibility, Java 2D, and Drag and Drop. Java
2D has e an integral part of AWT, Swing is built on top of AWT, and Accessibility support is built into Swing.
The five parts of JFC are certainly not mutually exclusive, and Swing is expected to merge more deeply with AWT in
future versions of Java. The Drag and Drop API was far from mature at the time of this writing but we expect this
technology to integrate further with Swing and AWT in the near future. Thus, AWT is at the core of