| Overview of the Java UI

## Classes in the Example Program

> The example program defines two classes that inherit from AWT classes. It also defines a data storing class. However, most of the objects in the program are instances of AWT classes.

> The following snapshot shows the example program's GUI. Each visible feature is labelled with the class that implements the feature. For example, the Converter class implements the object that draws the external box, and which contains every component in the program's GUI. The Converter class also happens to implement many features that aren't visible in the snapshot, such as the `main()` method that allows the program to run as an application.

> This page tells you about every object the program creates. Don't worry -- we don't expect you to understand everything yet. We just want to convey to you the kinds of objects a GUI program might use.

> #### Classes Defined in the Example Program

> > The example program defines two Panel subclasses, Converter and ConversionPanel, and a simple class named Unit.

> > The Converter class is the heart of the example program. It contains the program's `main()` method (which is called if the program is run as an application), as well as initialization and startup code, which is called either by the `main()` method or by the application that loads that program as an applet. The Converter class actually extends the Applet class (which itself extends Panel), instead of directly extending Panel. This is necessary because all applets must contain an Applet subclass. However, since the example program can also run as an application, the Converter class must not use any functionality provided by the Applet class. In other words, the Converter class must be implemented as if it extended Panel.

> > The ConversionPanel class provides a way of grouping all the controls that describe a particular set of distance measurements. The example program creates two ConversionPanel objects, one for metric distance measurements, and the other for U.S. distance measurements.

> > The Unit class provides objects that group a description (such as "Centimeters") with a multiplier that indicates the number of units per meter (0.01, for example).

> #### AWT Objects in the Example Program

> > The example program uses several LayoutManagers, Containers, and Components provided by the AWT package. It also creates two Insets objects and two GridBagConstraints objects.

> > The example program creates three objects that conform to the LayoutManager interface: a GridLayout and two GridBagLayouts. The GridLayout manages the layout of the Components in the Converter instance. Each ConversionPanel uses a GridBagLayout object to manage its Components, and a GridBagConstraints object to specify how to lay out each Component.

> > Besides the Converter and ConversionPanel objects, the example program can create one more Container. Specifically, if the program is run as an application (instead of as an applet), then it creates a Frame instance (an independent window).

> > All the non-container components in the example program are created by ConversionPanel. Each ConversionPanel contains one instance each of the AWT Label, Choice, TextField, and Scrollbar classes.

> > Both the Converter and the ConversionPanel classes create Insets instances that specify the padding that should appear around their onscreen representations.

> | Overview of the Java UI