The Creating a GUI with JFC/Swing trail tells you how to create graphical user interfaces (GUIs) for applications and applets, using the Swing components. The Swing components, which are part of the JavaTM Foundation Classes (JFC), can be used with either JDK 1.1 or JDK 1.2.
Note: This trail will soon be published as a book, The JFC Swing Tutorial. Please help us by sending your suggestions for improvement to firstname.lastname@example.org, with the subject "swing". Keep in mind that this is still a work in progress. Thanks!
Note: This trail does not tell you how to use the AWT components. If you need to write a JDK 1.0 program or a 1.1 program that doesn't use Swing components, then this trail is not for you! Instead, you can download an archive version of the old UI trail, Creating a User Interface (AWT Only).
Getting Started with Swing is a quick start lesson. First it gives you a bit of background about the JFC and Swing. Then it tells you how to compile and run programs -- both applications and applets -- that use Swing components. Finally, it walks you through the code for a simple program.
Swing Features and Concepts gives you the information you need to be able to use Swing components effectively. For example, it tells you how Swing programs display their GUIs, how they handle events such as mouse clicks, and how they can use features such as borders to help with layout. You should fully understand the information in this lesson before going on to other lessons in this trail.
Using Swing Components tells you how to use each of the Swing UI components.
Writing Event Listeners tells you how to handle events in your programs.
Laying Out Components within a Container tells you how to choose a layout manager, how to use each of the layout manager classes the Java environment provides, how to use absolute positioning instead of a layout manager, and how to create your own layout manager.
Working with Graphics tells you how to do everything from drawing lines and text to loading, displaying, and manipulating images. It includes information on performing animation and on improving graphics performance. Note: This lesson has not yet been converted to Swing.
Using Other Swing Features tells you how to use actions, borders, icons, and timers. It also tells you how to use threads correctly.
Converting to Swing tells you how to convert programs that use the 1.1 AWT API to use the Swing components.
Other tutorial coverage of UI topics is in the following places:
- 2D Graphics, which discusses the 2D graphics features added in JDK 1.2.
- Sound, which discusses the sound capabilities added in JDK 1.2.
- Writing Applets, which discusses API available only to applets, such as sound capabilities in JDK 1.0 and 1.1.
- Essential Classes discusses many topics, including properties and the standard I/O streams.