This lesson describes every component the AWT offers, including the
Canvasclass, 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
Canvas, you use Swing components such as
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 for details.
Using the AWT ComponentsStart 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! for information about deprecation and about differences between 1.0 and 1.1 programs.
Writing Event HandlersThis 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 ArchitectureThis 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.