Java SWING and Java AWT - Swing VS AWT

Java SWING and Java AWT - Swing VS AWT

exploreJava Logo

Table of Contents:

a) Introduction to Java GUI Programming
b) Java AWT (Abstract Window Toolkit) and its Components
c) Java Swing and its Components
d) Difference Between Java Swing and AWT



As, we know JAVA programming language is the high level programming language. It is used to create all types of the programs i.e Web-Based GUI Application, Android GUI Application and Desktop-Based GUI Applications. But in this tutorial series we are going to discuss about the Desktop-Based Applications. To study about the Desktop-Based GUI Application we must know about the SWING and AWT (Abstract Window Toolkit).

Java AWT (Abstract Window Toolkit):

 It is the part of the Java Foundation Classes(JFC) that is used to create the GUI based desktop applications. Inside this there are many classes which are used such as Frame, TextField, Button, Label etc. Its components are heavy weighted as it uses the computer resource to render them physically. Java.awt package is used to access the classes of the AWT API.

AWT Components:
            Button (java.awt.Button) 
            Checkboxes (java.awt.Checkbox)
             Radio Buttons (java.awt.CheckboxGroup)
             Choice Buttons (java.awt.Choice)
             Labels (java.awt.Label)
             TextFields (java.awt.TextField)

AWT Components hierarchy;
awt hierarchy


It is also the part of the Java Foundation Classes (JFC) that is used to create the GUI based Desktop Applications. It is the extended version of the AWT and is entirely written in java. Unlike AWT, it provides the platform independent and light weight components. Javax.swing package is used to access the classes of the SWING API such as JFrame, JTextField, JButton etc. Swing is a set of program components for java programmers that provide the ability to create graphical user interface (GUI) components, such as buttons, scroll bars, that are independent of the windowing system for specific operating system.

Some Components of SWING are:

JButton class
JRadioButton class
JTextArea class
JComboBox class
JTable class
JColorChooser class
JProgressBar class
JSlider class

SWING Components hierarchy;
swing hierarchy

[ Note: The Java Foundation Classes (JFC) are a set of GUI components which simplify the development of desktop applications.]

Here are the some Differences between the SWING and AWT:

Java AWT
Java Swing components are platform
Java AWT components are platform dependent.
Java Swing components are light weighted.
Java AWT components are heavy weighted.
Java Swing supports pluggable look and feel.
Java AWT does not supports pluggable look and feel.
It provides larger components than AWT.

Java Swing follows MVC model.

SWING provides huge variety of components than AWT such as tables, lists, scrollpanes, colorchooser, tabbedpane etc.
It provides less component than SWING.

Java AWT does not follows MVC model.

AWT provides less components compared to SWING.

Note: MVC (Model View Controller) where model represents data, view represents presentation and controller acts as an interface between model and view.

Conclusion: From this now you can say that SWING is far more better than the AWT. This is all about the Java SWING and Java AWT. Hope you are clear about these two things. If you find it informative then it will be awesome.

You Might also like this;

Basic GUI Methods in Java

Threads in Java

Post a Comment