Introduction To Programming In Java/Swing

About Swing Swing library is an official Java GUI toolkit released by Sun Microsystems. Swing is a lightweight component and does not use the native API's of the OS. The main characteristics of the Swing toolkit:

  • platform independent
  • customizable
  • extensible
  • configurable
  • lightweight

Swing is no longer the latest GUI toolkit for use with Java, being replaced by JavaFX. However, it will remain included in Java for the forseeable future. For more information, see the JavaFX Frequently Asked Questions.


  • 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.multi
  • javax.swing.plaf.synth
  • javax.swing.table
  • javax.swing.text
  • javax.swing.text.html
  • javax.swing.text.html.parser
  • javax.swing.text.rtf
  • javax.swing.tree
  • javax.swing.undo

Java Swing first programs

A basic test application for Swing is as follows:

import javax.swing.JFrame;

public class Test extends JFrame {
   public Test {
        setSize(300, 200);
  public static void main(String[] args) {
       Test test = new Test;

The constructor contains three function calls. The first two set the size and title of the window. The third statement is used to terminate the application once the window is closed; by default, the program will keep running even though the main function finishes. This is a change from non-graphical Java applications.


Project: Introduction to Programming in Java
Previous: Introduction to Programming in Java/Arrays — Introduction to Programming in Java/Swing — Next:

  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.


Manage research, learning and skills at IT1me. Create an account using LinkedIn to manage and organize your IT knowledge. IT1me works like a shopping cart for information -- helping you to save, discuss and share.

  Contact Us  |  About |  IT Training & References |  IT Careers |  IT Hardware |  IT Software |  IT Books