Java Blog

 
 
 
import java.awt.*;
import java.applet.*;

public class LifeCycle extends Applet
{
      private static int initcall, startcall, paintcall, stopcall, destroycall;

      public void init()
      {
          setBackground(Color.cyan);
          setForeground(Color.red);
          initcall=initcall+1;
      }

      public void start()
      {
           startcall=startcall+1;
      }

      public void paint(Graphics g)
      {
              paintcall=paintcall+1;
              g.drawString(\"init Method is called for  : \"+initcall,0,14);
              g.drawString(\"start Method is called for  : \"+startcall,0,30);
              g.drawString(\"paint Method is called for : \"+paintcall,0,46);
              g.drawString(\"stop Method is called for : \"+stopcall,0,62);
              g.drawString(\"destroy Method is called for : \"+destroycall,0,78);
              showStatus(\"Demo of Applet Life Cycle\");
     }

     public void stop()
     {
            stopcall=stopcall+1;
     }

     public void destroy()
     {
            destroycall=destroycall+1;
     }
}

 
 
Didn't find what you were looking for? Find more on Simple Applet which will show life cycle of an Applet