9.4. The Applet Life Cycle

Applet is an unusual class since the browser automatically creates an instance of it and calls certain methods at certain times. The main method is never called by the browser. Instead, the following placeholder methods are called at various times. The methods are empty unless overridden by the author.

public void init()

This method is called after the applet instance is first created by the browser. In Netscape, init is not called again if the applet is stopped and restarted unless the applet has been “trimmed” (deleted from memory) by the browser. In Internet Explorer, init is called whenever the user returns to the page containing the applet.

public void start()

The start method is called after init is completed, but ...

Get Core Web Programming, Second 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.