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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access