Difference B/W AWT and SWING AND JavaFX

INTRODUCTION | AWT, SWING, JavaFX

AWT, SWING, JavaFX are APIs. All of them used to develop GUI (Graphical User Interface).

what is GUI? GUI is an interface that interacts with user and source code. It makes the software user friendly. So, Users interact with the interface and that interface interacts with source code. 

Example of GUI- Calculator, All buttons are shown on-screen are components of GUI.

Also, The user is not interacting directly with code.

Fig 1: GUI Of Calculator.

Let’s discuss AWT, SWING, and JavaFX –

AWT

also, Its full form is Abstract Window Toolkit. Released in 1995 with java. It’s an API used to develop GUI for Windows-based applications in the Java programming language.

AWT is Platform dependent i.e, its components display according to the Architecture of the operating system. also, To use its components import java.awt.package. However, This package provides classes for it API like textField, label, text area, etc.

so, AWT components are heavyweight which means components use resources of the operating system. So, Programmers have control over it as the looks of components vary on different platforms.

Hence, It doesn’t follow MVC ( Model View Architecture Model ) where Model means data, View Architecture means presentation and Controller means Interface between model and view.

Hierarchy of AWT

Fig 2: Hierarchy Of AWT Components.

SWING

It’s an API used to develop GUI for desktop-based applications in the Java programming language. It was released in 1997 built on AWT.

So, its components display does not depend on the architecture of the operating system. To use SWING components import javaX, swing package. So, This package provides classes for SWING API like textField, label, text area, etc.

However, SWING components are lightweight which means components do not use many resources of the operating system.

so, It follows MVC ( Model View Architecture Model ) where Model means data, View Architecture means presentation and Controller means Interface between model and view.

SWING built on top of AWT API. However, it is also an extended version of itself. SWING has more components than it like the Radio button.

Hierarchy of SWING

Fig 3: Hierarchy Of SWING Components.

JavaFX

Also, To work with JavaFX no prerequisite knowledge of any other technology required. However, The package needed to import JavaFX.util  has a graphical processing unit.

It provides graphics pipelines which accelerate graphical processing without external storage JavaFX also provides canvas and printing APIs,  support drag and drop facility, etc.

Hence, Styling provided by JavaFX is like CSS. the number of components in JavaFX is more than AWT but less than SWING.

Tabular difference

CHARACTERISTIC            AWT          SWING          JavaFX
DEPENDENCYPlatform      dependentPlatform independentPlatform independent
WEIGHT OF COMPONENTHeavyweightLightweightLightweight
CURRENTLY IN USEDiscardedUse it in a few places.Currently in use
PLUGGABLEDoes Not support a pluggable look and feelsupport pluggable look and feel. Components look the same on all systemssupport pluggable look and feel. Components look the same on all systems.
MVCDoes Not Follow MVCFollow MVCFollow MVC.
NO. OF COMPONENTSlessMore than AWTMore than AWT but less than SWING.
PACKAGEjava.awt.packagejavax.swingjavafx.util
RELEASED199519972008

CONCLUSION:

Hence, it is not in use currently. Also, SWING is in use at some places. JavaFX is also in use.

SWING has more components than JavaFX but JavaFX GUI is more modern and rich than SWING’s GUI. It will discard totally in the next few years So, it’s better to learn JavaFX.

Written by: Yatika Yadav

Reviewed By: Soutik Maity

If you are Interested In Machine Learning You Can Check Machine Learning Internship Program
Also Check Other Technical And Non Technical Internship Programs

Leave a Comment

Your email address will not be published. Required fields are marked *