Java Swing - Building GUIs

Professor Futrelle -- College of Computer Science, Northeastern U., Boston, MA

Updated 21 September 2004 - again 4 September 2005


Introduction

Swing is Sun's large collection of Java resources for constructing graphical user interfaces (GUIs). Swing can be used for constructing full-fledged applications, e.g., Eclipse and jEdit, or applets to display in browsers. This page contains useful links to online Swing resources, including source code from Sun's own 2004 book. Google works fine for virtually any kind of question you might have about the Swing and/or Java.

Also see my page on Java resources.

Running the Swing demos on CCIS Solaris systems

To run the newest version:
java -jar /usr/demo/J2SE/demo/jfc/SwingSet2/SwingSet2.jar &

To run an older version:
java -jar //usr/demo/JAVA1.2/demo/jfc/SwingSet/SwingSet.jar &

In Mac OS X, the directory with the SwingSet2 demo application is
/Developer/Examples/Java/JFC/SwingSet2/
There, you can run the application. I was also able to run the applet version via the html page there in Firefox (v 0.9.3).

The demo gives you a choice of demos to run as well as the source code for each one which you can cut and paste for yourself.

Code examples from the O'Reilly Swing book, 2nd. edition

Access the Swing examples, with source code here (on the O'Reilly site).

Some major systems built with Swing

An interesting collection of substantial applications written with Swing can be found here.

Java 2D - The graphics component of Java

Swing is focused on building GUIs (windows, menus, text, etc.) Graphics 2D is what is used more for computer graphics. Here is the Graphics 2D Tutorial.

A book -- Hardcopy and on-line

A search on Amazon for books containing the words java and swing inside the text returns 7,800. If the search is confined to titles or subjects, 17 book titles are returned. So picking out a few to suggest here is not easy!

But the primary one I'll describe, with additional source code resources, is the book developed by Sun which is free online at this location, as well as available as a hardcopy from any bookdealer. It is The JFC Swing Tutorial: A Guide to Constructing GUIs, 2nd Edition by Kathy Walrath, et al. (Addison Wesley, 2004). In Fall 2004, this book was on Reserve in Snell Library for ISU570, Human Computer Interaction. In the list below, I've collected together links to the source code for all the examples in the book.

The online book and examples are updated steadily.


Go to Futrelle's Teaching Gateway

Return to Prof. Futrelle's home page