Previous | Next | Trail Map | Creating a User Interface (AWT Only) | Contents

Using Components, the GUI Building Blocks

This lesson describes every component the AWT offers, including the Canvas class, which you can use to build your own custom components. This lesson also describes the AWT component architecture and has details on writing event handlers.

Note: We recommend that instead of using AWT components such as Button and Canvas, you use Swing components such as JButton and JComponent. The Swing components, which are part of the Java Foundation Classes (JFC), can be used with either JDK 1.1 or JDK 1.2. See Using the JFC/Swing Packages(in the Creating a User Interface trail) for details.

Using the AWT Components

Start here to learn the general rules of using components, as well as details on how to use every component the AWT provides.

Note: The text and the code snippets in this section reflect 1.0, unless otherwise noted. However, each page that features an example has links to both 1.0 and 1.1 versions of the example. Remember: 1.0 code runs in 1.1 environments, but it often results in warnings when compiled in 1.1, due to its use of deprecated API. See To 1.1 -- And Beyond!(in the To 1.1 -- And Beyond! trail) for information about deprecation and about differences between 1.0 and 1.1 programs.

Writing Event Handlers

This section gives an overview of and general tips on writing event handlers. It then goes on to give details about each kind of event handler you might need to implement.

Note: The text and the code snippets in this section reflect 1.1.

Details of the Component Architecture

This section tells you about peers. A peer is an object that provides the look (and part of the feel) for standard components. You usually don't need to know about peer objects, since they're specific to platform implementations. However, sometimes knowing about peers can help you find bugs in event-handling, drawing, or layout code.

Common Component Problems (and Their Solutions)

This section discusses solutions to common component-related problems.


Previous | Next | Trail Map | Creating a User Interface (AWT Only) | Contents