Lifecycle of Applet

Author posted by Jitendra on Posted on under category Categories JAVA and tagged as Tags with Leave a comment on Lifecycle of Applet

Example which shows the 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");

Related posts

Leave a Reply