September 17, 2003

Understanding the applet life cycle

 

Run this applet and view the messages in the console window.



/*
An applet to understand the applet life cycle and its basic structure
*/
import java.awt.*;
   import java.applet.Applet;
public class AppletStructure extends Applet
{
   public void init() {
      System.out.println("initializing");
   } // init
   
   public void start() {
      System.out.println("starting");
   }// start
   
   public void paint(Graphics g) {
      System.out.println("painting");
   g.drawString("Hello World!", 30, 30);
   } // paint
   
   public void stop() {
      System.out.println("stopping");
   }// stop
}// AppletStructure
Back to class exmaples | Back to CS110 Materials page