Creating a GUI with JFC/Swing TMThe Java Tutorial Search Start of Tutorial Feedback Form Examples Index
Trail: Creating a GUI with JFC/Swing 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 TMcomponents, which are part of the Java Foundation Classes (JFC), can be used with TM TMeither JDK 1.1 or the Java 2 platform. 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, please download the old UI trail, Creating a User Interface (AWT Only). This trail is available as a book, The JFC Swing Tutorial . Besides having the usual advantages of a book (such as portability and readability) this 950-page tome contains a CD that has API documentation, the JFC 1.1 and JDK 1.1 releases, the latest available releases of the Java 2 SDK, and lots of other goodies. A shorter, simpler introduction to using the Swing components is published in the book The Java Tutorial, 3rd Edition . You can find it online here: User Interfaces that Swing: A Quick Start Guide. 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. ...
Creating a GUI with JFC/Swing
TMThe Java Tutorial
Search
Start of Tutorial Feedback Form
Examples Index
Trail: Creating a GUI with JFC/Swing
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
TMcomponents, which are part of the Java Foundation Classes (JFC), can be used with
TM TMeither JDK 1.1 or the Java 2 platform.
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, please download the old UI trail, Creating a User Interface
(AWT Only).
This trail is available as a book, The JFC Swing Tutorial .
Besides having the usual advantages of a book (such as
portability and readability) this 950-page tome contains a CD
that has API documentation, the JFC 1.1 and JDK 1.1 releases,
the latest available releases of the Java 2 SDK, and lots of other
goodies.
A shorter, simpler introduction to using the Swing components is published
in the book The Java Tutorial, 3rd Edition . You can find it online here:
User Interfaces that Swing: A Quick Start Guide.
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
http://java.sun.com/docs/books/tutorial/uiswing/index.html (1 of 3) [10/28/2001 1:51:25 PM]l
l
l
l
l
Creating a GUI with JFC/Swing
such as borders to help with layout. It ends with a discussion of how the features and
concepts are used by a real program.
Using Swing Components tells you how to use each of the Swing components --
buttons, tables, text components, and all the rest.
Using Other Swing Features tells you how to use actions, borders, icons, and timers.
It also helps you to create multithreaded programs.
Laying Out Components Within a Container tells you how to choose a layout
TMmanager, how to use each of the layout manager classes the Java platform provides,
how to use absolute positioning instead of a layout manager, and how to create your own
layout manager.
Writing Event Listeners tells you how to handle events in your programs.
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.
Converting to Swing tells you how to convert programs that use the 1.1 AWT API to
use the Swing components.
Although this is the main trail for learning about GUIs, it isn't the only trail with UI-related
information. Here are some other trails that discuss UI topics:
2D Graphics , which describes the 2D graphics features available in the Java 2
platform.
Sound , which discusses the sound capabilities available in the Java 2 platform.
Writing Applets , which describes API available only to applets, such as sound
capabilities in JDK 1.0 and 1.1.
Essential Java Classes , which covers many topics, including properties and the
standard I/O streams.
The Bonus trail contains Full-Screen Exclusive Mode API , a lesson that describes
how to use API introduced in v1.4 to render graphics directly to the screen.
Your feedback is important to us! Please send your comments and
suggestions to us using the feedback page.
http://java.sun.com/docs/books/tutorial/uiswing/index.html (2 of 3) [10/28/2001 1:51:25 PM]Creating a GUI with JFC/Swing
Search
Start of Tutorial Feedback Form
Examples Index
Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.
http://java.sun.com/docs/books/tutorial/uiswing/index.html (3 of 3) [10/28/2001 1:51:25 PM]Creating a GUI with JFC/Swing: Table of Contents
TMThe Java Tutorial
Search
Start of Tutorial > Start of Trail Feedback Form
Examples Index
Trail: Creating a GUI with JFC/Swing: Table of
Contents
User Interfaces that Swing: A Quick Start Guide
Overview of the Swing API
Your First Swing Program
Example Two: SwingApplication
Example Three: CelsiusConverter
Example Four: LunarPhases
Example Five: VoteDialog
Layout Management
Threads and Swing
Summary
Questions and Exercises: User Interfaces That Swing
Getting Started with Swing
About the JFC and Swing
Compiling and Running Swing Programs
Compiling and Running Swing Programs (Java 2 Platform)
Compiling and Running Swing Programs (JDK 1.1)
Running Swing Applets
A Quick Tour of a Swing Application's Code
Swing Features and Concepts
Swing Components and the Containment Hierarchy
Layout Management
Event Handling
Painting
Threads and Swing
More Swing Features and Concepts
The Anatomy of a Swing-Based Program
http://java.sun.com/docs/books/tutorial/uiswing/TOC.html (1 of 5) [10/28/2001 1:51:26 PM]Creating a GUI with JFC/Swing: Table of Contents
Using Swing Components
A Visual Index to the Swing Components
The JComponent Class
Using Top-Level Containers
How to Make Frames (Main Windows)
How to Make Dialogs
How to Make Applets
Using Intermediate Swing Containers
How to Use Panels
How to Use Scroll Panes
How to Use Split Panes
How to Use Tabbed Panes
How to Use Tool Bars
How to Use Internal Frames
How to Use Layered Panes
How to Use Root Panes
Using Atomic Components
How to Use Buttons, Check Boxes, and Radio Buttons
How to Use Color Choosers
How to Use Combo Boxes
How to Use File Choosers
How to Use Labels
How to Use Lists
How to Use Menus
How to Monitor Progress
How to Use Sliders
How to Use Tables
Using Text Components
An Example of Using Each Text Component
General Rules for Using Text Components
How to Use Text Fields
Concepts: About Editor Panes and Text Panes
Summary of Text
How to Use Tool Tips
How to Use Trees
Solving Common Component Problems
Using Other Swing Features
http://java.sun.com/docs/books/tutorial/uiswing/TOC.html (2 of 5) [10/28/2001 1:51:26 PM]Creating a GUI with JFC/Swing: Table of Contents
How to Use Actions
How to Support Assistive Technologies
How to Use Borders
How to Use Icons
How to Set the Look and Feel
How to Use Threads
How to Use Timers
Solving Common Problems Using Other Swing Features
Laying Out Components Within a Container
Using Layout Managers
General Rules for Using Layout Managers
How to Use BorderLayout
How to Use BoxLayout
How to Use SpringLayout
How to Use CardLayout
How to Use FlowLayout
How to Use GridLayout
How to Use GridBagLayout
How to Use GridBagLayout: Specifying Constraints
How to Use GridBagLayout: The Example Explained
Creating a Custom Layout Manager
Doing Without a Layout Manager (Absolute Positioning)
Solving Common Layout Problems
Writing Event Listeners
Some Simple Event-Handling Examples
General Information about Writing Event Listeners
Listeners Supported by Swing Components
Implementing Listeners for Commonly Handled Events
How to Write an Action Listener
How to Write a Caret Listener
How to Write a Change Listener
How to Write a Component Listener
How to Write a Container Listener
How to Write a Document Listener
How to Write a Focus Listener
How to Write an Internal Frame Listener
http://java.sun.com/docs/books/tutorial/uiswing/TOC.html (3 of 5) [10/28/2001 1:51:26 PM]Creating a GUI with JFC/Swing: Table of Contents
How to Write an Item Listener
How to Write a Key Listener
How to Write a List Data Listener
How to Write a List Selection Listener
How to Write a Mouse Listener
How to Write a Mouse-Motion Listener
How to Write a Table Model Listener
How to Write a Tree Expansion Listener
How to Write a Tree Model Listener
How to Write a Tree Selection Listener
How to Write a Tree-Will-Expand Listener
How to Write an Undoable Edit Listener
How to Write a Window Listener
Summary of Listener API
Solving Common Event-Handling Problems
Working with Graphics
Overview of Custom Painting
Using Graphics Primitives
Painting Shapes
Working with Text
Using Images
Loading Images
Displaying Images
Performing Animation
Creating an Animation Loop with Timer
Moving an Image Across the Screen
Displaying a Sequence of Images
Improving the Appearance and Performance of Image Animation
Solving Common Graphics Problems
Converting to Swing
Why to Convert
How to Convert
Conversion Resources
Swing Replacements for AWT Components
General Conversion Tips
Component-Specific Conversion Tips
http://java.sun.com/docs/books/tutorial/uiswing/TOC.html (4 of 5) [10/28/2001 1:51:26 PM]Creating a GUI with JFC/Swing: Table of Contents
Some Conversion Examples
Solving Common Conversion Problems
Search
Start of Tutorial > Start of Trail Feedback Form
Examples Index
Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.
http://java.sun.com/docs/books/tutorial/uiswing/TOC.html (5 of 5) [10/28/2001 1:51:26 PM]Creating a GUI with JFC/Swing: Indexes of Examples
TMThe Java Tutorial
Search Start of Tutorial > Start of Trail
Feedback Form
Trail: Creating a GUI with JFC/Swing: Indexes of
Examples
Getting Started with Swing: Examples
Swing Features and Concepts: Examples
Using Swing Components: Examples
Using Other Swing Features: Examples
Laying Out Components: Examples
Writing Event Listeners: Examples
Working with Graphics: Examples
Converting to Swing: Examples
Search Start of Tutorial > Start of Trail
Feedback Form
Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.
http://java.sun.com/docs/books/tutorial/uiswing/examples.html [10/28/2001 1:51:27 PM]Getting Started with Swing: Examples
TMThe Java Tutorial
Search S