In 1997, Sun Microsystems and IBM decided to solve the problem of access-enabling software. Their aim was to develop such an accessibility API that application developers could implement on Java class libraries to make applications accessible. As the result, Sun Microsystems wrote the accessibility API and IBM has tested their API and implemented it on their foundation classes. Sun Microsystems integrated JFC/ Swing directly into Java 1.2 and later versions. In this section, we are going to discuss the JFC, its components, services, and the difference between JFC and AWT.
What if JFC?
JFC stands for Java Foundation Classes. It is a rich and comprehensive set of GUI components and services that simplify the development and deployment of desktop, client-side, and internet applications. It is a superset that contains AWT. JFC extends AWT by adding many components and services that are as follows:
|Swing GUI Components
||It includes everything from buttons to split panes to tables. Many components are capable of sorting, printing, and drag and drop, to name a few of the supported features.
|Pluggable Look-and-Feel Support
||The look and feel of Swing applications is pluggable, allowing a choice of look and feel. For example, the same program can use either the Java or the Windows look and feel. Additionally, the Java platform supports the GTK + look and feel, which makes hundreds of existing looks and feels available to Swing programs. Many more look-and-feel packages are available from various sources.
||It is a part of JFC that works with alternate input and output devices. It enables assistive technologies, such as screen readers, screen magnifiers, and Braille terminals, to get information from the UI.
|Java 2D API
||It enables developers to easily incorporate high-quality 2D graphics, text, and images in applications and applets. Java 2D includes extensive APIs for generating and sending high-quality output to printing devices.
||It allows developers to build applications that can interact with users worldwide in their own languages and cultural conventions. With the input method framework, developers can build applications that accept text in languages that use thousands of different characters, such as Japanese, Chinese, or Korean.
|Drag and Drop (DnD)
||Drag and Drop is one of the more common metaphors used in GUI. The user is allowed to click and "hold" a GUI object, moving it to another window or frame in the desktop with predictable results. It allows users to implement droppable elements that transfer information between Java applications and native applications. Although DnD is not part of Swing, it is crucial to a commercial-quality application.
Sun Microsystems added a mechanism to the JFC is called Multiplexed UI. It is an extension to the PLAF (Pluggable Look & Feel). A key feature of the PLAF is that it enables developers to swap the Look and Feel of the UI which can be directly accessible. It was developed for application developers to provide a common interface.
The Multiplexed UI mechanism allows the developer to:
- Add multiple alternative UI to the JFC component library while JVM starts.
- Makes multi-modal access (such as hands-free voice access) features possible with a smaller amount of development effort.
The following figure describes the JFC architecture.
In the above figure, we see that Swing sits atop of part, but not all, of the AWT components. Swing sits on a number of the APIs that implement the various parts of AWT, including Java2D, Drag-and-Drop, and the Accessibility API.
Advantage of JFC
- Its components are pluggable and require few lines of code.
- It retains Java qualities.
- An application that runs flawlessly on one OS runs flawlessly on another OS.
- It offers an open architecture.
Accordingly, the exhibition of a GUI made through JFC is unsurprising. Therefore, JFC are widely used in client-side applications.
Components of JFC
The JFC components includes all the JavaBeans and swing Components that offer re-usability, interoperability, and portability. Note that Swing is an enhancement of AWT, not a replacement.
Difference Between JFC and WFC
|It supports robust and portable interfaces.
||It runs only on the Windows (32-bit) user interface that require Microsoft extension.
|It provides greater control over user interface because of object-oriented nature.
||The number of controls available for WFC is probably smaller than for JFC.
|It requires more memory.
||It requires less memory.
|Its performance is slower than WFC.
||Its performance is faster than JFC.
|It is used to build complex user interface.
||It is used to build simple user interface.