Features of Swing in Java

Swing is a GUI toolkit that facilitates the creation of highly interactive GUI applications. Swing is more flexible and robust when it comes to implementing graphical components. Swing can be regarded as more graphically rich than AWT not only because they provide some entirely new graphical components like a tabbed window and tree structure. Some of the key swing classes are given as below:




Swing Class Description
JAppletIt is an extension of Applet class, it is the swing's version of the applet.
JFrameIt is an extension of java.awt.Frame class, it is the swing's version of the frame.
JButtonIt helps to realize a push button in the swing.
JTabbedPaneIt helps to realize a tabbed pane in the swing.
JTreeIt helps to realize a hierarchical tree or structure in the swing.
JComboBoxIt helps to realize a combo box in the swing.

A Swing GUI consists of two key items:

    1. Components
    2. Containers

Components:

In Swing, Components are derived from the JComponent class where JComponent provides the functionality that is common to all components.
Example: JComponent supports the pluggable look and feel.

Containers:

JComponent inherits the AWT classes Container and Component. Thus, a Swing component is built on and compatible with an AWT component. All of Swing’s components are represented by classes defined within the package [java]javax.swing[/java].

A Container holds a group of components. Thus, a container is a special type of component that is designed to hold other components. Thus, all Swing GUIs will have at least one container. Because containers are components, a container can also hold other containers.

Swing Packages:

Swing is a very large subsystem and makes use of many packages. These are the packages used by Swing are given below:

javax.swing javax.swing.borderjavax.swing.colorchooser
javax.swing.eventjavax.swing.filechooser javax.swing.plaf
javax.swing.plaf.basicjavax.swing.plaf.metaljavax.swing.plaf.multi
javax.swing.plaf.synthjavax.swing.tablejavax.swing.text
javax.swing.text.htmljavax.swing.text.html.parserjavax.swing.text.rtf
javax.swing.treejavax.swing.undo