O'Reilly logo

Platinum Edition Using XHTML™, XML, and Java™ 2 by Andrew H. Watt, Mike Morgan, Jim O'Donnell, Eric Ladd

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Life Cycle of an Applet

You've seen Applet's paint() method. As you might guess, repainting the screen is only one part of an applet's life cycle. This section shows the various stages of an applet's life and suggests various tasks you might want to undertake at each step. To see these steps in action, compile LifeCycle.java given in Listing 36.4. You can construct an HTML file based on the pattern given in HelloApplet.html—just change the name of the class file.

Code Listing 36.4. LifeCycle.java—Stages in the Life of an Applet
 import java.applet.Applet; import java.awt.Graphics; public class LifeCycle extends Applet { public LifeCycle() { System.out.println("Constructor running..."); } public void init() { System.out.println("This is init."); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required