Previous | Next | Trail Map | Creating a User Interface (with Swing) | Contents

Using the JFC/Swing Packages

The Java Foundation Classes (JFC) include many ready-to-use components, nicknamed Swing components. This lesson tells you how to use the Swing components, using the Swing 1.1 Beta 3(in the API reference documentation) API, which is provided in the JFC 1.1 (Swing 1.1 Beta 3) release.

Even if you can't yet update to the Swing 1.1 Beta 3 API, you can still use our code. In general, all you need to do is substitute com.sun.java for all occurrences of javax. (See the Swing Package Names section for more information.) When we describe API that was added in a Swing 1.1 beta release, we try to give you workarounds to use for earlier releases.


This is a draft! Please help us improve this lesson by sending comments and suggestions to tutorial@java.sun.com, putting the word "swing" in the subject. Once this lesson is finished, it and a Swing version of the rest of the UI trail will be published by Addison-Wesley as The JFC Swing Tutorial: A Guide to Constructing GUIs.

This lesson was last updated October 5, 1998. Changes include updating all examples to Swing 1.1 Beta 3, adding a page about package names, and incorporating reviewers' comments. We also added a discussion of cell-specific renderers to the Further Customizing... section of the table page. If you've already downloaded the tutorial, you can update your copy of this lesson; see Download The Java Tutorial.


Getting Started with Swing

To write programs using the Swing components, you must first download the appropriate JDK and JFC releases. Then you can compile and run the "Hello Swing" application that we provide. Next, take a tour of the "Hello Swing" program to learn how a Swing program works.

Overview of the Swing Components

This section shows you each Swing component and then links to where you'll learn how to use the component. Here's a preview of what you'll see:

Using Each Swing Component

The Swing components conform to the Swing architecture, which means that they are lightweight, have a pluggable look and feel, conform to the requirements of JavaBeans, and so on. Despite the plethora of features, the components are easy to use.

This section first gives you an overview of code that you might use when using any Swing component. Then each component has a subsection that tells you all about using that component.

Using the Common Swing Events

Swing defines a few event types to supplement the AWT events. This section tells you about the most commonly used Swing events.

Using Other Swing Features

This section tells you how to use Swing features such as actions, borders, box layout, icons, and timers. It also covers topics such as using threads in Swing programs.


Previous | Next | Trail Map | Creating a User Interface (with Swing) | Using the JFC/Swing Packages