Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg7068951

HOUR 12:Making the Most of Existing Objects

At the top is the Objectclass.JApplethas five superclasses above it in the
hierarchy: Applet,Panel,Container,Component, and Object.
TheJAppletclass inherits attributes and behavior from each of these class-
es because each is directly above it in the hierarchy of superclasses. JApplet
does not inherit anything from the five green classes in Figure 12.1, which
includeDialogandFrame, because they are not above it in the hierarchy.
If this seems confusing, think of the hierarchy as a family tree. JApplet
inherits from its parent, the parent’s parent, and on upward. It even might
inherit some things from its great-great-great-grandparent, Object. The
JAppletclass doesn’t inherit from its siblings or its cousins, however.
Creating a new class boils down to the following task: You only have to
define the ways in which it is different from an existing class. The rest of
the work is done for you.

Inheriting Behavior and Attributes
The behavior and attributes of a class are a combination of two things: its
own behavior and attributes and all the behavior and attributes it inherits
from its superclasses.
The following are some of the behavior and attributes of JApplet:

. Theequals()method determines whether a JAppletobject has the
same value as another object.


WINDOW

DIALOG

FILEDIALOG

CONTAINER

COMPONENT

OBJECT

PANEL

APPLET

JAPPLET

SCROLLPANE

FRAME

The family tree of the JApplet
class.

Free download pdf