An Applet to Demonstrate the Life Cycle of an Applet - Java Applet

Java examples for Applet:Applet Creation

Description

An Applet to Demonstrate the Life Cycle of an Applet

Demo Code

import javax.swing.JApplet;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class Main extends JApplet {
  private int startCount = 0;
  private int stopCount = 0;

  @Override// www.j a  v a2  s . c om
  public void init() {
    getContentPane().add(new JLabel("Applet Life Cycle!!!"));
    JOptionPane.showMessageDialog(null, "init()");
  }

  @Override
  public void start() {
    startCount++;
    JOptionPane.showMessageDialog(null, "start(): " + startCount);
  }

  @Override
  public void stop() {
    stopCount++;
    JOptionPane.showMessageDialog(null, "stop(): " + stopCount);
  }

  @Override
  public void destroy() {
    JOptionPane.showMessageDialog(null, "destroy()");
  }
}

Related Tutorials