«^»
2.2. What the Swing API includes and how it is organised

The package javax.swing consists of many classes. It provides GUI components such as buttons, checkboxes, lists, menus, tables, text areas, and trees. It also includes GUI components that are containers (such as menu bars and windows), and higher-level components (such as dialog boxes, including dialog boxes for opening or saving files). And there are also classes for basic drawing operations, and for manipulating images, fonts and colours, and for handling events such as mouse clicks.

Many of these GUI components will have common features. For example, there is a method called setBackground that can be used to alter the background colour of a component. Although it would be possible to include a method declaration called setBackground in each of the classes, this is not sensible. Because Java has inheritance, it allows classes to be arranged in a class hierarchy: this means the Swing designers can declare the setBackground method in a class high up in the class hierarchy and it is automatically available in the classes that are lower down in the class hierarchy. So, an extensive class hierarchy is used to organise the classes of the Swing API (and the AWT).