Back to Examples of Using the JDK 1.1 AWT

Lightweight Components

Starting with the JDK 1.1 Beta 3 release, the AWT supports lightweight components. Lightweight components are essential in the following situations:

This page tells you how to create lightweight components, and then gives you links to examples -- pages with applets that use lightweight components (source code included, of course). For more details about what lightweight components are and how they work, see Java AWT: Lightweight UI Framework.

How to Create Lightweight Components

To create a lightweight component, you need to create a class that directly extends one of the following classes:

Your class needs to provide both the look and the feel of the component. You'll typically need to implement the following methods:

Lightweight components place special requirements on their containers:

Code Examples and Applets

This section links to four pages, each with an example that illustrates an aspect of lightweight components. Each page includes one applet and links to the applet's source code. If you're using a browser that includes support for 1.1beta3, then your browser will be able to run the applet on each page. Otherwise, you'll need to use another tool, such as the JDK Applet Viewer, to view the applet on each page.


Note: You must use a 1.1 browser such as HotJava or the JDK Applet Viewer to view the applets on the following pages. If you have trouble running the applets, go here.

Here are the examples:

Round Button Example
Demonstrates how easy it is to create a lightweight component.

Openlook Button Example
Modifies the Round Button example to show a more realistic looking lightweight component.

Spinner Example
Demonstrates how to animate a lightweight component.

Gauge Example
Demonstrates how to animate a lightweight component using double buffering to eliminate flicker. Contains sourced code for both 1.1-only and "Swing" versions of the example. For more information on Swing, browse the the Swing release documentation.


Back to Examples of Using the JDK 1.1 AWT
By Kathy Walrath