Home : Course Map : Chapter 6 : Java :
AWT - Abstract Windows Toolkit
JavaTech
Course Map
Chapter 6

Introduction
AWT
Swing
Containers
  Demo 1
UI Components
  Demo 2
UI Layout
  Demo 3   Demo 4
Text Display
  Demo 5
Drawing
  Demo 6   Demo 7
Draw Polygons
  Demo 8   Demo 9
Colors
Text Draw 
  Demo 10
Images
  Demo 11
Exercises

    Supplements
AWT
  Demo 1
Drawing
  Demo 2
Text Drawing
  Demo 3
UI Components
  Demo 4

Java2D
Shapes & Areas
  Demo 1   Demo 2
Stroke & Paint
  Demo 3
Transforms
  Demo 4
Gradients&Textures
  Demo 5   Demo 6
Text
  Demo 7   Demo 8
     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

The following diagram shows most of the the class heirarchy of the AWT (Abstract Windows Toolkit), which comes as part of the core Java language (java.awt package and sub-packages.)

The key Component class provides the base class for all the AWT visual components and also for the Swing components. The class provides a very large number of public methods - see the API description for Component.

The container class provides for holding instances of other component classes. The Window subclass, for example, provides for the top level visible containers, Frame and Dialog, that hold various visible components.

Containers can hold other containers. The Panel class, in particular, is used within a top level container to arrange its sub-components, which often are also panels. An elaborate GUI display with lots of buttons, textfields, and other components will employ several panels and sub-panels to arrange the visible atomic (non-container) components.

As seen in the diagram above, the basic AWT includes several atomic components such as buttons, labels, and textfields. You can create fairly elaborate GUI displays with these tools.

Lightweight Wins Over Heavyweight

However, as mentioned in the introduction, there are a number of limitations to these components. For example, simply creating a subclass of Button for a custom button that displays an icon is not practical. Java programs before 1.2 became know for a bland, dull appearance and limited capabilities.

The basic problem is that these components are closely tied to so-called peer component classes written in native code for the local operating system GUI. This means that Java portability required a lowest-common-denominator approach in which no visible component could provide more capability that what was available on all platforms. This results in very limited options in how the components can look and perform. These basic AWT components are called heavyweight because they drag along all the peer component coding.

A far more flexible approach is to open a heavyweight top level class, such as a frame, and then just let Java draw all the visible sub-components without involving any local peer components. Such lightweight components are very flexible, especially when combined with the more powerful event handling structure that came with Java vers. 1.1 (event handling will be discussed in Chapter 7: Java)

The Swing set of classes (available in the javax.swing and related packages) consists primarily of lightweight components. Swing first became available as an independent set of code that would work with version 1.1 and then was included in the standard Java distribution for version 1.2. Swing will be discussed in more detail in the next section.

Though there are some drawbacks to Swing (see the next section), It is now generally recommended that everyone switch their Java user interface design from AWT to Swing for all serious program development for PC and equivalent platforms.

Note: In some cases, such as when developing programs for small platforms, it can be necessary to remain within the older AWT framework. We discuss small platform programming in Chapter 24. See the Chapter 6: Supplements section for a brief overview of creating user interfaces purely within the basic AWT framework.

 

Latest update: Oct.25, 2004

            Tech
Java Tech Graphics
Starting to Plot
  Demo 1
Drawing Panel
  Demo 2
Histogram Display

  Demo 3
Exercises

           Physics
Display Text Data
  Demo 1
Plot Data
  Demo 2
Find Max/Min
  Demo 3
Exercises

  
  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.