Select Page

What are the Java Foundation Classes (JFC)?

The Java Foundation Classes are group of classes that are used to create graphical user interface for java applications.

nanadwumor

May 27, 2023
Java Foundation Classes2

The Java Foundation Classes are group of classes that are used to create graphical user interface for java applications.

Why are these  classes called foundation classes?

They are called foundation classes because most of the client side java Applications are built upon these API’s or classes.

 


Join other Subscribers on our YouTube channel and enjoy daily pogramming tutorials.


What is a Graphical User Interface (GUI)?

A graphical user interface (GUI) of an application is a program that allows a user interact with the application through the use of elements such as buttons, icons, visual metaphors.

Graphical User Interface

Example of graphical user interface of Photoshop

What comprises the JFC?

The JFC comprises the Abstract Windowing Toolkit (AWT), Java2D and Swing.

The JFC, AWT , Java2D,  Swing

Java programmers use the JFC to create GUI for their applications. For example, if you want to create a game app like Fruit Ninja, you have to code all the logic of the game that makes the game functions as you want. But after all these, you need to wrap a GUI around the code so that a user can play or interact with your game.

 

Recommended


So the buttons you click to install the app, change volume, etc form the GUI. Without it, the user cannot interact with the raw code working behind the scene. So you can think of the GUI as an insulator around the live code.

The AWT

AWT is short for Abstract Windowing Toolkit. The AWT is the bedrock upon which other API’s of the JFC are built. The AWT allows Java programmers to write applications and applets that interact with the user through windows and other GUI components.

How does the AWT work?

The AWT doesn’t draw GUI components itself. That’s, the components such as buttons the user interact with are not directly built by the AWT classes. The AWT classes rather interact with another layer of classes called the Peer classes and direct these peer Classes to instruct the underlining operating system to draw the GUI components.

Now, let’s put this simple. Suppose you’re using a Windows Operating system. If you are using an application built with the AWT, then the components you’re seeing aren’t drawn by the AWT itself. They’re rather drawn on the screen by the Windows Operating system classes responsible for drawing graphics on the screen.

 However, AWT will be the API passing instructions to the Windows classes through another layer of software called the Peer classes.

 This might look like a smart process but it’s not without its problems.

AWT components are heavyweight

AWT components are called heavyweight components because they rely on peer Classes of the underlying operating system. Because it always needs these peer Classes to function, it makes the AWT “heavy”.

Problems with the AWT

Java2D is built upon the AWT. It expands on the graphics functionalities in Java 1.0 and 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.

Java2D

Java2D is built upon the AWT. It expands on the graphics functionalities in Java 1.0 and 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.

Swing

Swing is a GUI API. It has a lot of classes for creating graphical user interface. Swing is an alternative for AWT. It’s more powerful and versatile. Few of the classes in swing rely on the underlining classes of the Operating system.

Most of the swing classes draw graphic components on their own unlike the AWT which always depend on third-party classes of the native OS. 

Swing was released to remedy the major problems posed by the use of the AWT.

Unlike the AWT, Swing components can be easily customized.

They can have the same “look and feel” across different Operating systems because they don’t rely on these Operating systems to create its graphics.

Swing is lightweight

Swing components are called lightweight components. This is because with the exception of few, majority of its classes don’t need any peer Classes. This makes them “light”, hence, lightweight.


Share this article


You May Also Like…

double data type in Java

double data type in Java

The double data type is also a floating point number. It is called double because it has a double-precision decimal...

float data type in Java

float data type in Java

It is a floating point number. It has single precision data type. It stores a floating point number of 7 digits of...