
The Java Foundation Classes bring new capabilities to the Java programmer, foremost among which are the components in the so-called Swing set.This chapter begins by looking briefly at the history of the Java programming la guage and of the Abstract Window Toolkit in particular. The Abstract Window Toolkit, or AWT for short, provides the classes used to build an application’s user interface. In both Java Development Kit (JDK) 1.0 and JDK 1.1, Java applications running under Windows looked just like Windows programs, while those running on Solaris looked the same as native applications written with the Motif toolkit. The reason for this was simply that much of the AWT is provided by code from the native platform’s windowing system—the user interface components are rendered by Windows or by Motif, not by Java code. While this has its advantages, it also has drawbacks. For one thing, it is difficult to implement a single interface and map it to two (or more) host platforms that work differently. And even when you’ve done that, the controls themselves behave somewhat differently between the platforms. Because this behavior is part of the native windowing system, there’s nothing you can do about it.
Implementing all of the user interface classes in Java gets rid of these problems at a stroke. hat’s exactly what the Swing components, which are the most significant part of the Java Foundation Classes (JFC), do—they replace the native
implementation with a user interface library that works the same on all Java platforms.
This chapter starts by looking at the history of the Swing project and then moves
on to look at the new architecture that was developed to implement the Swing controls. The power of this architecture will be shown toward the end of the chapter,when you’ll see how simple it is to change the way an application built with Swing controls looks, without changing a single line of code.
No comments:
Post a Comment