|
|
Contents |
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 2API, which is provided in the JFC 1.1 (Swing 1.1 Beta 2) release. With the few exceptions that we note, our code is compatible with Swing 1.0.3
and Swing 1.1 Beta (which is included in JDK 1.2 Beta 4
).
This is a work in progress! Please help us improve this lesson by sending comments and suggestions to tutorial@java.sun.com, putting the word "swing" in the subject. Keep an eye on this section of the tutorial and The Swing Connection for the latest information on the Swing project.This lesson was last updated September 7, 1998. Changes include updating to Swing 1.1 Beta 2; writing the descriptions of color choosers, file choosers, and progress monitors; and improving the descriptions and examples for several Swing components, such as lists and tables. If you've already downloaded the tutorial, you can update your copy of this lesson; see Download The Java Tutorial.
This Swing lesson, together with a Swing version of the rest of the UI trail, will soon be published by Addison-Wesley as The JFC Swing Components: A Tutorial Guide to Constructing GUIs. We're almost done! So please send us your picky (yet constructive) comments, putting "swing" in the subject of your message.
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.Writing Lightweight Components Using the Swing Release
This section will tell you how to write simple components, using subclasses of Swing components. (It's easy!) For now, you can look at two examples. The first is a ruler used as a header in the scroll pane example:Rule.javaThe second is a custom button in the Bingo example:NumberButton.
|
|
Using the JFC/Swing Packages |