This is the code for the program that allows you to press a button and change the message:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Guess extends Applet implements ActionListener
{
Label greeting = new Label("Who's the greatest?");
Font normalFont = new Font("TimesRoman", Font.PLAIN,16);
Button pressMe = new Button("Press Me");
public void init()
{
greeting.setFont(normalFont);
add(greeting);
add(pressMe);
pressMe.addActionListener(this);
}
public void actionPerformed(ActionEvent thisEvent)
{
Font bigFont = new Font("TimesRoman", Font.ITALIC,30);
Label answer = new Label("");
answer.setFont(bigFont);
answer.setText("Lloyd is!!!");
add(answer);
remove(greeting);
remove(pressMe);
invalidate();
validate();
}
}