This program simply checks to see when each method is executed. However, when I run it in an AppletViewer my applet displays absolutely nothing. Could anyone provide any suggetions? I've provided both files below. Thank you for your help.
<HTML>
<APPLET CODE = "LifeCycle.class" WIDTH = 450 HEIGHT = 200>
</APPLET>
</HTML>
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class LifeCycle extends Applet implements ActionListener
{
/*Declares the names of six methods that execute during
the full lifetime of the applet. Declares a button "pressButton."
Declares six integers that hold the number of occurences of each
of the six methods.*/
Font buttonFont = new Font("TimesRoman", Font.ITALIC,12);
Label messageInit = new Label("init ");
Label messageStart = new Label("start ");
Label messageDisplay = new Label("display ");
Label messageAction = new Label("action ");
Label messageStop = new Label("stop ");
Label messageDestroy = new Label("destroy");
Button pressButton = new Button("Press");
int countInit, countStart, countDisplay,
countAction, countStop, countDestroy;
/*The Init() method adds one to countInit, places
all components within the applet and calls
the display() method.*/
public void Init()
{
++countInit;
add(messageInit);
add(messageStart);
add(messageDisplay);
add(messageAction);
add(messageStop);
add(messageDestroy);
add(pressButton);
pressButton.setFont(buttonFont);
pressButton.addActionListener(this);
display();
}
//The Start() method adds one to countStart and calls the display method.
public void start()
{
++countStart;
display();
}
/*The diplay method adds one to countDisplay and displays the name of
each of the six methods with the current count and indicates how
many times the method has executed.*/
public void display()
{
++countDisplay;
messageInit.setText("Init " + countInit);
messageStart.setText("Start " + countStart);
messageDisplay.setText("display " + countDisplay);
messageAction.setText("action " + countAction);
messageStop.setText("stop " + countStop);
messageDestroy.setText("destroy " + countDestroy);
}
/*The stop() and destroy() methods each add one to the appropriate
counter and call the display() method.*/
public void stop()
{
++countStop;
display();
}
public void destroy()
{
++countDestroy;
display();
}
/*When the user clicks the button "pressButton", the following
actionPerformed() method executes. It adds one to countAction
and displays it.*/
public void actionPerformed(ActionEvent e)
{
++countAction;
display();
}
}