Presentation

A GUI is an assembly of GUI components such as button, menus, and views:

Note that the Singleton pattern can be used to prevent an application from inadvertently having multiple GUIs.

The Graphical Context

Instances of the Graphics class are called graphical contexts. They represent virtual graphics devices such as monitors:

The GUI Component Hierarchy

We can think of the GUI as a customized view. A GUI is also an assembly of GUI components. This suggests using the Composite pattern:

The Shape Hierarchy

A graphical context draws shapes. Each shape has a location and size (usually specified by a bounding box). We can think of a shape such as a CAD/CAM model of a car as an assembly of component shapes representing tires, body, etc. This suggests using the Composite pattern again to build shape hierarchies:

Next, let's see how we can make GUI's platform independent.