Establishing Inheritance

A class is defined as the subclass of another class using the extends statement, as in the following:

class AnimatedLogo extends JApplet {    // behavior and attributes go here}

The extends statement establishes the AnimatedLogo class of objects as a subclass of JApplet. As you see during Hour 17, “Creating Interactive Web Programs,” all Swing applets must be subclasses of JApplet. They need the functionality this class provides to run when presented on a web page.

One method that AnimatedLogo must override is the paint() method, which is used to draw everything within the program’s window. The paint() method, implemented by the Component class, is passed all the way down to AnimatedLogo. However, the paint() method does ...

Get Sams Teach Yourself Java™ in 24 Hours, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.