What Is the JFC?

   

Java Foundation Classes (JFC) provides a framework for developing Java programs with user interfaces. This framework can be conveniently divided into five major APIs: AWT (Abstract Windowing Toolkit), Swing, Accessibility, Java 2D, and Drag and Drop. AWT is the foundation of the JFC, whereas Swing is built on top of the AWT. Accessibility is mainly built into Swing, although it is also being added to the AWT ”this is a work in progress. Finally, Java 2D and Drag and Drop are built into the AWT.

AWT

Since its inclusion with the first Java development kit, the AWT has provided developers with the means to create event-driven graphical user interfaces (GUIs) for their Java programs. The AWT also supports primitive graphics operations (such as drawing text and shapes , displaying images, manipulating colors, and choosing fonts). Furthermore, the AWT makes it possible to create flicker-free animations, process images, and print graphics.

Although the AWT generated a lot of excitement when it was first released, developers soon became aware of its limitations. These limitations include the following:

  • The AWT relies on the host computer's operating system (OS) to provide visual and interactive GUI components . Therefore, it isn't easy to create a GUI with a consistent look and feel across all OSes that support the Java Virtual Machine. For example, suppose you want to use the AWT to develop a program with IBM's OS/2 graphical look and event-driven feel. Furthermore, you want to run this program under another OS (such as Windows 2000) and have its users perceive this program as one that looks and feels like a program running under OS/2. Unfortunately, this scenario is not easy to achieve under the AWT.

  • The AWT uses the lowest -common denominator components and component features to ensure that an AWT-based Java program will work under all OSes that support the JVM. As an example of the first situation, not all OSes supported table and tree components when the AWT was initially released. Therefore, the AWT could not support tables or trees. As an example of the second situation, the AWT does not support Motif's tear-off menu feature because this feature is not implemented by the menu components of any Windows OS. Because tear-off menus are not in the lowest-common denominator of menu features, they are not part of the AWT.

  • The AWT's graphics capabilities are very limited in what they can do. For example, it is not possible to control either the thickness or the style (such as dashed or dotted ) of a shape's borders.

See Chapter 13, "Beginning AWT" .

Swing

Swing was developed to address the AWT's GUI limitations. With Swing, it is possible to create GUIs that are richer than their AWT counterparts in appearance and capabilities.

The classes and interfaces that constitute Swing provide new components (such as trees, tables, and split panes). Swing also introduces a concept known as pluggable look and feel. Pluggable look and feel makes it possible to design a GUI that looks and feels the same on every platform, or that adapts its look and feel to a specific platform. For example, a program could choose to look and feel like a Motif program when run under Unix, Windows and MacOS, or it could choose to look and feel like a Motif program when run under Unix, a Windows program when run under Windows, and a MacOS program when run under MacOS. (The latter case is accomplished by giving Swing programs access to the system look and feel.) Swing also provides access to its own default cross-platform look and feel, known as Metal (or Java).

Note

You might be wondering where Swing got its name . Swing was christened at the 1997 JavaOne conference in San Francisco. Swing engineers used a music-based demonstration to showcase Swing components. Among the jokes that were passed back and forth, one of the engineers suggested that Swing was being considered the "in" sound in music. Because the Swing classes did not yet have a name and because its engineers felt that it would be the "in" GUI development technology for Java, they decided to call this unnamed technology Swing. After all, for many developers and users of Java technology, "GUIs don't mean a thing if they ain't got that Swing."


See Chapter 16, "Building a GUI: Swing Style" .

Accessibility

People who are afflicted with varying physical challenges (such as blindness or diminished loss of vision, loss of limbs , and so on) can find software usage either impossible or next to impossible . And then there are times (such as when driving a car with both hands on the wheel) when an individual who is not physically challenged might find it difficult to use software. In either situation, software accessibility is beneficial.

Accessibility includes support for alternative input and output devices (such as speech recognition/synthesis devices, Braille keyboards, and screen magnifiers). The accessibility portion of the JFC makes it almost transparent for software to support these devices.

Accessibility provides the mechanism by which automation software can be created. This software can automatically send keystrokes, mouse clicks, and mouse movements to a program for testing, screen magnification, and other purposes.

See Chapter 17, "Accessibility" .

Java 2D

Java 2D was developed to address the AWT's graphics limitations. For example, AWT's rectangle, arc, and polygon shapes are not sufficient for an automotive designer who needs access to advanced shapes (such as B zier curves) for modeling curved surfaces.

Java 2D offers many features that are not part of the AWT's graphics package. These features include

  • The ability to decide the width and style (dashed, dotted, solid) of the pen used to draw a shape's outline

  • The ability to fill the interior of an arbitrary shape with a solid color or pattern

  • The ability to determine what happens when two shapes overlap

  • The ability to transform a shape through scaling, rotation, translation, or some other operation

  • The ability to clip to an arbitrary shape

  • The ability to detect mouse clicks in an arbitrary shape through advanced hit detection

  • The ability to use any available font to display text

  • A sophisticated printing model for complex documents

  • Improved image processing capabilities

See Chapter 18, "Java 2D" .

Drag and Drop

Drag and Drop supports the dragging and dropping of objects between Java programs, or between Java and non-Java programs. For example, it is possible to create a Java program that functions as a file manager. A user can select a graphical image (such as a file icon) and drag this image off of the file manager program and onto a Linux word processor program or a Macintosh trash can icon. As a result, Drag and Drop helps improve application interoperability.

See Chapter 19, "Drag and Drop" .

   


Special Edition Using Java 2 Standard Edition
Special Edition Using Java 2, Standard Edition (Special Edition Using...)
ISBN: 0789724685
EAN: 2147483647
Year: 1999
Pages: 353

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net