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. AWTSince 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:
See Chapter 13, "Beginning AWT" . SwingSwing 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" . AccessibilityPeople 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 2DJava 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
See Chapter 18, "Java 2D" . Drag and DropDrag 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" . |