Java Applet Life-cycle Program Java by Rajesh Kumar Sahanee - September 20, 2015September 20, 20150 Post Views: 9,295 Hello friends today I’m going to show you life-cycle of Java Applet. Applet is a Java Program which runs in browser and can also be run and tested using appletviewer command in java. Applet runs in browser that means it is executed at client side. To run applet, client should have Java installed in his/her computer. Applet code is downloaded from web server before it is executed. Applet Life-cycle Program AppletLifecycle.java Java import java.awt.*; import java.applet.Applet; import javax.swing.JOptionPane; public class AppletLifecycle extends Applet { TextArea messages = new TextArea(8, 30); public AppletLifecycle() { add(messages); messages.append("Constructor executed\n"); } public void init() { messages.append("init method executed\n"); } public void start() { messages.append("start method executed\n"); } public void paint(Graphics g) { messages.append("Paint called\n"); } public void stop() { JOptionPane.showMessageDialog(null, "Stop method executed"); } public void destroy() { JOptionPane.showMessageDialog(null, "Destory method executed"); } } /* <applet code="AppletLifecycle.class" width="300" height="300">Not supported</applet> */ 123456789101112131415161718192021222324252627282930313233343536373839 import java.awt.*;import java.applet.Applet;import javax.swing.JOptionPane; public class AppletLifecycle extends Applet { TextArea messages = new TextArea(8, 30); public AppletLifecycle() { add(messages); messages.append("Constructor executed\n"); } public void init() { messages.append("init method executed\n"); } public void start() { messages.append("start method executed\n"); } public void paint(Graphics g) { messages.append("Paint called\n"); } public void stop() { JOptionPane.showMessageDialog(null, "Stop method executed"); } public void destroy() { JOptionPane.showMessageDialog(null, "Destory method executed"); } } /*<applet code="AppletLifecycle.class" width="300" height="300">Not supported</applet>*/ To run this applet using appletviewer command type appletviewer AppletLifecycle.java in command prompt. To run this applet in browser create a html file and copy commented applet tag code in html file, and open that html file in browser. Output in AppletViewer After clicking close button of this window we will get below message box After clicking OK button we will get below message box Thanks.. You can share if you like it