Applet lifecycle methods

In this example we shall show you the Applet lifecycle methods. A Java applet is a special kind of Java program that a browser enabled with Java technology can download from the internet and run. An applet is typically embedded inside a web page and runs in the context of a browser. An applet must be a subclass of the java.applet.Applet class. The Applet class provides the standard interface between the applet and the browser environment. The Applet lifecycle methods are the ones below:

as described in the code snippet below.

package com.javacodegeeks.snippets.core;
import java.applet.Applet;
import java.awt.Graphics;
public class AppletLifecycleMethods extends Applet {
	
	private static final long serialVersionUID = 5872447536017036208L;
	// Called by the browser or applet viewer to inform
	// this applet that it has been loaded into the system.
    public void init() {
    }
    // Called by the browser or applet viewer to inform
    // this applet that it should start its execution.
    public void start() {
    }
    // Called by the browser or applet viewer to inform
    //this applet that it should stop its execution.
    public void stop() {
    }
    // Called by the browser or applet viewer to inform
    // this applet that it is being reclaimed and that it
    // should destroy any resources that it has allocated.
    // The stop method will always be called before destroy. 
    public void destroy() {
    }
    // Paints the container. This forwards the paint to any
    // lightweight components that are children of this container.
    public void paint(Graphics g) {
    }
}
<applet code=com.javacodegeeks.snippets.core.AppletLifecycleMethods width=100 height=100>
</applet>

 
This was an example of Applet lifecycle methods in Java.

Exit mobile version