Swing: A Quick Tutorial for AWT Programmers

APL Logo

This tutorial is now obsolete. Please see updated materials in the coreservlets.com Java programming tutorials.


"Swing" refers to the new library of GUI controls (buttons, sliders, checkboxes, etc.) that replaces the somewhat weak and inflexible AWT controls. This tutorial is aimed at getting Java programmers who already know the AWT going as quickly as possible in Swing. Tutorial © 1999 Marty Hall. All source code freely available for unrestricted use. Created for work in the Research and Technology Development Center of the Johns Hopkins University Applied Physics Lab, for courses in the Johns Hopkins Part-Time MS Program in Computer Science, and for various industry seminars and Java short courses.

CWP/2E

Expanded Table of Contents

Introductory Material
Using Top-Level Containers
  • JApplet
    • General Info
    • Differences from Applet
    • Example
  • JFrame
    • General Info
    • Differences from Frame
    • Example
  • Look & Feel
    • LAF Availability
    • Specifying Native LAF
    • Examples
Simple Swing Components
  • JLabel
    • Basics
    • New Features: Images, Borders, and HTML Content
    • Example
  • JButton
    • Basics
    • New Features: Icons, Alignment, Mnemonics, and HTML Content
    • Example
  • JPanel
    • Basics
    • New Features: Borders
    • Example
  • JSlider
    • Basics
    • New Features: Tick Marks and Labels
    • Example
  • JColorChooser
    • Basics
    • Example
Simple Swing Components, continued
Complex Swing Components
  • JList
    • General Info on MVC, Custom Data Models, and Custom Cell Renderers
    • JList with Fixed Set of Choices
    • JList with Changeable Choices
    • JList with Custom Data Model
    • JList with Custom Renderer
  • JTree
    • Basic JTree
    • Handling JTree Events
    • Custom Models and Dynamic JTrees
    • Changing the Node Icons
Other Swing Capabilities
  • Printing
    • Background
    • Printing Basics
    • The Role of Double Buffering
    • A General-Purpose Component-Printing Routine
    • Example