Site icon TestingDocs.com

Introduction to Java Swing API

Overview

In this tutorial, we will learn about Java Swing API. Java Swing API is a set of APIs that provides GUI(Graphical User Interface ) for Java programs. Java Swing is a part of Java Foundation Classes (JFC). JFC contains features for building Graphical User Interfaces.

Java Swing is developed based on AWT(Abstract Window Toolkit ) APIs.Swing provides more sophisticated GUI components than AWT. The AWT GUI components can be used from java.awt package.

 

Swing Features

Swing provides various layout managers to arrange GUI components inside a container.

Swing offers various button types such as push-button, check box, radio button, etc

Swing provides various text components and dialog boxes.

Swing enables pluggable Look & Feel to allow Java applications to have look and feel independent from the underlying platform. This allows Swing GUI components to have a uniform Look-and-Feel for the Java application across all platforms. We can also customize the application to use the platform’s custom Look-and-Feel.

Swing Packages

We need to import the Swing components in the Java code. The entire package using the below statement:

import javax.swing.*;

Individual component classes like:

import javax.swing.JFrame;

 

 

Some of the Swing packages are as follows:

Swing Package Description
javax.swing This package contains the core Swing components, including the model Interfaces and Helper classes.
javax.swing.event This package defines Listeners & Events which Swing components use to communicate asynchronously.

Java Tutorial on this website:

https://www.testingdocs.com/java-tutorial/

For more information on Java, visit the official website :

https://www.oracle.com/in/java/

Exit mobile version