Chapter 3. Using Swing Components

 <  Day Day Up  >  

Chapter 3. Using Swing Components

http://java.sun.com/docs/books/tutorial/uiswing/components/index.html

This chapter gives you the background information you need to use Swing components. It assumes that you've successfully compiled and run programs that use Swing components and that you're familiar with basic Swing concepts. These prerequisites were covered in the previous two chapters.

This chapter doesn't tell you how to use a particular Swing components. Once you're ready to start using Swing components in your own programs, you should read the relevant how-to sections in Chapter 7, Individual Components Reference (page 147). For example, if your program needs a frame, a label, a button, and a color chooser, you should read How to Make Frames (Main Windows), How to Use Labels, How to Use Buttons , and How to Use Color Choosers. We recommend that you at least skim this chapter first. Here's a quick overview:

  • A Visual Index to Swing Components pictures all the standard Swing components, from top-level containers to scroll panes to buttons.

  • Using HTML in Swing Components describes how to vary the font, color, or formatting of text displayed by Swing components by using HTML tags.

  • Using Top-Level Containers discusses how to use the features shared by the JFrame , JDialog , and JApplet classes: content panes, menu bars, and root panes. It also discusses the containment hierarchy, which refers to the tree of components in a top-level container.

  • Using Models tells you about the Swing model architecture. This variation on Model-View-Controller (MVC) means that you can specify how the data and state of a Swing component are stored and retrieved. The benefits are the ability to share data and state between components and the ability to greatly improve the performance of components, such as tables, that display large amounts of data.

  • The JComponent Class tells you about the features JComponent provides to its subclasses ”which include almost all Swing components ”and gives tips on how to take advantage of these features. The section ends with API tables describing the commonly used API defined by JComponent and its superclasses, Container and Component .

  • Using Text Components describes the features and API shared by all components that descend from JTextComponent . You probably don't need to read this section if you're just using text fields (formatted or not) or text areas.

  • At the end of this chapter is the Summary, followed by Questions and Exercises. Finally, Example Programs lists all the examples in this chapter and indicates where you can find them on the CD and online.

A Visual Index to Swing Components

Using HTML in Swing Components

Example One: HtmlDemo

Example Two: ButtonHtmlDemo

Using Top-Level Containers

Top-Level Containers and Containment Hierarchies

Adding Components to the Content Pane

Adding a Menu Bar

The Root Pane (The Missing Details)

Using Models

An Example: Converter

For More Information

The JComponent Class

JComponent Features

The JComponent API

Using Text Components

Text Component Features

Associating Text Actions with Menus and Buttons

Associating Text Actions with Keystrokes

Implementing Undo and Redo

Concepts: About Documents

Implementing a Document Filter

Listening for Changes on a Document

Listening for Caret and Selection Changes

Concepts: About Editor Kits

The Text Component API

Summary

Questions and Exercises

Example Programs

 <  Day Day Up  >  


JFC Swing Tutorial, The. A Guide to Constructing GUIs
The JFC Swing Tutorial: A Guide to Constructing GUIs (2nd Edition)
ISBN: 0201914670
EAN: 2147483647
Year: 2004
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net