站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Java Tutorial 5.0 英文版

Learning Swing by Example - Java Tutorial 5.0 英文版

The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form
Examples Index (1.4)

Trail: Creating a GUI with JFC/Swing

Lesson: Learning Swing by Example

This lesson explains the concepts you need to use Swing components in building a user interface. First we examine the simplest Swing application you can write. Then we present several progressively complicated examples of creating user interfaces using components in the javax.swing package. We cover several Swing components, such as buttons, labels, and text areas. The handling of events is also discussed, as are layout management and accessibility. This lesson ends with a set of questions and exercises so you can test yourself on what you抳e learned.

Note: Most of the topics this lesson discusses are covered in depth in later lessons--for example, you can get detailed information on how to use components from Using Swing Components (in the Creating a GUI with JFC/Swing trail). This lesson is designed for readers who want to learn the basics quickly by examining some simple examples.

Note: You can download all the examples (including images) used in this trail from the Example Index.
Example One: Your First Swing Program (in the Creating a GUI with JFC/Swing trail)
This small example has all the code that every Swing application must have.

Example Two: SwingApplication (in the Creating a GUI with JFC/Swing trail)
This section takes you through the code for a small Swing application. The topics covered include: look and feel, setting up buttons and labels, handling events, and adding borders.

Example Three: CelsiusConverter (in the Creating a GUI with JFC/Swing trail)
The third example, a program that converts a given temperature from Celsius to Fahrenheit, illustrates how to add an event listener to a text field and display the converted temperature on a label.

Example Four: An Improved CelsiusConverter (in the Creating a GUI with JFC/Swing trail)
The fourth example improves our temperature conversion example and illustrates how to add HTML and icons to components, setting the default button and how to create a formatted text field.

Example Five: LunarPhases (in the Creating a GUI with JFC/Swing trail)
The fifth example covers how to set up multiple panels, compound borders, combo boxes, and how to load multiple images.

Example Six: VoteDialog (in the Creating a GUI with JFC/Swing trail)
You can vote for your favorite political candidate in the final example, VoteDialog. This application illustrates the use of radio buttons and dialogs.

Summary (in the Creating a GUI with JFC/Swing trail)
A summary of important concepts covered in this section.

Questions and Exercises (in the Creating a GUI with JFC/Swing trail)
Try these questions and exercises to test what you've learned in this lesson.


Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form
Examples Index (1.4)

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.