Java Foundation Classes and Swing

Java Foundation Classes (JFC) is a collection of classes that provide everything you need to develop GUI applications. Swing happens to be a part of JFC, and JFC itself is incorporated into Java 2.

JFC includes the following major components:

• Swing GUI components are lightweight GUI components for Java applications and applets. For the latest information on Swing classes and some programming tips, see The Swing Connection, an online newsletter at http://java.sun. com/products/jfc/tsc/. Swing does not replace AWT. Rather, Swing extends AWT by adding more class libraries that support all aspects of GUI programming.

• Accessibility APIs allow developers to create GUI applications that can support people with disabilities such as limited sight or the inability to operate a mouse. For more information on the accessibility features, visit Sun's website at http:// java.sun.com/products/jfc/jaccess-1.2.2/doc/ and browse the online accessibility documentation.

• Java 2D API is a set of classes for two-dimensional (2D) graphics and imaging. In particular, Java 2D API provides more control over the image rendering process. For more information on Java 2D API, visit the Java 2D API home page at http://java.sun.com/products/java-media/2D/. If you have JDK 1.2 installed, you can see what Java2D offers by running the Java2Demo program, which should be in the demo/jfc/Java2D subdirectory of the location where you installed JDK 1.2. (Use the command java Java2Demo to start the demo program.)

• "Drag and drop" refers to the ability to cut and paste text and images between Java applications (as well as other applications running on your system). You can download the latest Drag and Drop specification from http://java.sun.com/ j2se/1.5.0/docs/guide/dragndrop/spec/dnd1.html. In Java 2, the java.awt.dnd package includes the interfaces and classes for supporting drag-and-drop operations.

Swing happens to be the largest part of JFC. Originally, Swing was released as a separate class library that could be used with Java 1.1 class libraries. However, when Java 2 was officially released in December 1998, the Swing classes were included in it. The Swing classes are in various packages with names that begin with javax.swing.

JFC is essentially layered on the AWT, which, in turn, relies on the native windowing system (such as Microsoft Windows or Motif) to render the user interface on the display. Figure 26-4 illustrates the layered model of JFC. As the figure shows, the Swing components rely on parts of the AWT but not all of it. AWT components use the native windowing system to display output and receive user input from the mouse and keyboard. AWT components such as buttons, labels, panels, and frames are still available for use. The Accessibility APIs are closely tied to Swing components, but the Java2D API and Drag and Drop also rely on the native windowing system. Finally, Java GUI applications rely on the Swing components and they can also use the AWT components, if necessary.

Java GUI Applications

Swing Components

AWT Components

Accessibility APIs

Java 2D APIs

Abstract Windowing Toolkit

Drag and Drop

(AWT)

Native Windowing System

Figure 26-4: The Layered Model of Java Foundation Classes (JFC).

Was this article helpful?

0 0
Make Money Writing

Make Money Writing

This Report Will Show You How To Make Money By Providing Writing Services To Other Internet Marketers. Learn how to make money by writing the right way. Grab your copy of this report now and learn. Why writing is a great way to earn money. How to compete with cheap writers, even if you charge a lot more money.

Get My Free Ebook


Post a comment