Chapter 1. The Java Foundation Classes
The Java Foundation Classes, or JFC, is a loose collection of
standard Java APIs for client-side graphics, graphical user
interfaces (GUIs), and related programming tasks. They are
foundation classes in the sense that most client-side Java
applications are built upon these APIs. This book covers the
Although the most powerful and exciting features of the JFC
were introduced in Version 1.2 of the Java 2 platform, the JFC also includes the graphics
and GUI features of Java 1.0 and Java 1.1. These features are
provided by the Abstract Windowing Toolkit (AWT). The
graphics and GUI capabilities of the AWT are rudimentary, and
many of them have been superseded by more advanced features
in Java 1.2. Nevertheless, the AWT
is the bedrock upon which more advanced JFC functionality is
In addition, there are certain situations in which you cannot
take advantage of the new JFC functionality and must
instead rely solely on the AWT. For example,
common web browsers do not yet support Swing, so if you
are writing applets, you have to use the AWT. Because of
this, the graphics and GUI APIs of the
AWT are discussed right along with the more powerful APIs
introduced in Java 1.2.
Swing is an advanced GUI toolkit written in pure Java. It is
built upon the AWT but provides many new GUI
components and useful GUI-related application services.
Swing offers a pluggable look-and-feel architecture that
allows an application to be trivially configured either to
platform-independent Java look-and-feel or to mimic the
look-and-feel of the native operating system.
Swing also includes an
accessibility API that enables the use of assistive
technologies, such as screen readers or screen magnifiers for
the vision impaired. Many features of Swing are based on the
pioneering design of the Netscape Internet Foundation Classes.
Swing is a core part of the Java 2 platform. It is also
available, however, as an extension to Java 1.1.
Java 2D is the name for the state-of-the-art two-dimensional
graphics API introduced in Java 1.2. Java 2D is built upon the
AWT, but greatly expands on the graphics capabilities that
were available in Java 1.0 and Java 1.1. Java 2D includes
support for resolution independence, rotation, scaling and
shearing of arbitrary graphics, antialiasing of text and
graphics, alpha transparency, color compositing, and the use
of the full range of fonts installed on the native system.
The ability to print text and graphics on a page is almost as
important as the ability to draw text and graphics on the
screen. Java 1.1 introduced simple printing capabilities as
part of the AWT, and Java 1.2 includes a more powerful printing
API as part of the JFC. This book describes both printing
An important feature of many client-side applications is the
ability to allow user-directed data transfer within the
application and between unrelated applications. There are two
commonly used data transfer metaphors: cut-and-paste and
drag-and-drop. Java 1.1 defined a basic data transfer
framework and provided an API for cut-and-paste. Java 1.2 adds
support for data transfer using the drag-and-drop metaphor.
The applet API allows a client-side program to run as an applet,
or mini-application, within a web browser or some other form
of applet viewer. Technically, the applet API is not
part of the JFC, but it is a crucial piece of the
client-side Java programming picture and is included in this
The rest of the chapters in Part 1, "Introducing the Java Foundation Classes" describe these APIs in far
more detail. Read Chapter 2, "Swing and AWTArchitecture", first. After
reading that chapter, you can read the remaining chapters in
whatever order you prefer. The goal of each chapter is to introduce
an API in enough detail so that you can begin to use it in your
programs. While reading a chapter, you may
find it helpful to refer to the quick-reference material in
Part 2, "API Quick Reference"
of this book to find detailed API information on the individual
classes you are reading about.
Copyright © 2001 O'Reilly & Associates. All rights reserved.