Introduction to the Java Foundation Classes

snottybugbearSoftware and s/w Development

Nov 3, 2013 (4 years and 8 months ago)


to the Java
Topics in This Chapter
• The History of the Java Foundation Classes
• Overview of JFC Features
• The Swing Packages
• Look-and-Feel and the Model-View-Controller
he 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 lan-
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 window-
ing 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. That’s exactly what the Swing components, which are the most significant
part of the Java Foundation Classes (JFC), do—they replace the native implementa-
tion 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 con-
trols. 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.