Java Reference
In-Depth Information
When designing a hierarchy of classes, you ask yourself which features and behaviors
are common to all the classes that you are designing. Those common properties are
collected in a superclass. For example, all user interface components have a width
and height, and the getWidth and getHeight methods of the JComponent
class return the component's dimensions. More specialized properties can be found in
subclasses. For example, buttons can have text and icon labels. The class
AbstractButton , but not the superclass JComponent , has methods to set and
get the button text and icon, and instance fields to store them. The individual button
classes (such as JButton , JRadioButton , and JCheckBox ) inherit these
properties. In fact, the AbstractButton class was created to express the
commonality among these buttons.
Figure 3
A Part of the Hierarchy of Ancient Reptiles
443
Search WWH ::




Custom Search