Introduction
In this article, we discuss Java Swing as used for "Graphics programming in Java". We discuss the basic classes of Swing, why we use it, its advantages and a comparison with AWT.
Swing in Java
It is a Java Graphical User Interface (GUI) toolkit. It is an Application Programming Interface (API) for providing a Graphical User Interface (GUI) for Java programs.
It is a part of the JFC (Java Foundation Classes), that is an API for providing a graphical user interface for Java programs.
It is used to create a GUI with Java.
Need for Swing
Since we already have a class AWT for a GUI, why do we need Swing for GUI? Here are some points that describe the need of Swing:
- lightweight
- configurable
- platform-independent
- customizable
- extensible
Swing Hierarchy

Swing Packages
The main packages in swing are:
- javax.swing.text
- javax.swing.plaf.multi
- javax.swing.text.html
- javax.swing.text.html.parser
- javax.swing.text.rtf
- javax.swing.tree
- javax.swing.undo
- javax.accessibility
- javax.swing
- javax.swing.border
- javax.swing.colorchooser
- javax.swing.event
- javax.swing.filechooser
- javax.swing.plaf
- javax.swing.plaf.basic
- javax.swing.plaf.metal
- javax.swing.plaf.synth
- javax.swing.table
It is an update GUI toolkit. It adds various components to our window frame like lables, buttons, scrollbars, tables and trees.
Example
In this program we make a simple window without any extra features or functionality.


Comments
Join the conversation! Your thoughts help the community grow.