import java.awt.*; import java.applet.*; public class LifeCycle extends Applet { int nInit, nStart, nStop, nDestroy; Label initLbl = new Label("init() has not occurred"); Label startLbl = new Label("start() has not occurred"); Label stopLbl = new Label("stop() has not occurred"); Label destroyLbl = new Label("destroy() has not occurred"); public void init() { setLayout(new GridLayout(4,1)); nInit++; initLbl.setText("init() has occurred " + nInit + " times"); add(initLbl); add(startLbl); add(stopLbl); add(destroyLbl); System.out.println("init()"); } public void stop() { nStop++; stopLbl.setText("stop() has occurred " + nStop + " times"); System.out.println("stop()"); } public void start() { nStart++; startLbl.setText("start() has occurred " + nStart + " times"); System.out.println("start()"); } public void destroy() { nDestroy++; destroyLbl.setText("destroy() has occurred " + nDestroy + " times"); System.out.println("destroy()"); } }