Lifecycle of Applet

Applet is a piece of program in which runs on JAVA enabled browsers.

LifeCycle of Applet:

  • init()  is called only once  in lifecycle of applet during creation.
  • destroy() is called only once in applet lifecycle during disposal of applet.
  • whenever applet gots focus(active) paint() is called.
  • whenever applet is minimized stop() is called.
  • whenever applet is maximized start() & paint() is called.
  • start(), stop() & paint(Graphics g) can be called many times in applet lifecycle.

Example :


package com.shivasoft.applet;

import java.applet.Applet;
import java.awt.Graphics;

public class AppletLifecycle extends Applet
{
  public void init()
  {
      System.out.println("Init State");
  }

  public void start()
  {
      System.out.println("Start State");
  }

  public void paint(Graphics g)
  {
      System.out.println("Paint State");
   }

   public void stop()
   {
        System.out.println("Stop State");
   }

   public void destroy()
   {
        System.out.println("Destroy State");
    }
}

Posted

in

by

Tags:


Related Posts

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading