A Complete Applet Skeleton

Although SimpleApplet shown earlier is a real applet, it does not contain all of the elements required by most applets. Actually, all but the most trivial applets override a set of methods that provide the basic mechanism by which the browser or applet viewer interfaces to the applet and controls its execution. These lifecycle methods are init( ), start( ), stop( ), and destroy( ), and they are defined by Applet. A fifth method, paint( ), is commonly overridden by AWT-based applets even though it is not a lifecycle method. It is inherited from the AWT Component class. Since default implementations for all of these methods are provided, applets do not need to override those methods they do not use. These four lifecycle ...

Get Java, A Beginner's Guide, 5th Edition, 5th 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.