import java.applet.*;
import java.awt.*;
public class Button1Applet extends Applet{
public void init() {
add(new Button("Red"));
add(new Button("Blue"));
}
public boolean action(Event evt, Object whatAction) {
if (!(evt.target instanceof Button)) {
return false;
}
String buttonLabel = (String) whatAction;
if (buttonLabel == "Red") {
setBackground(Color.red);
} else if (buttonLabel == "Blue") {
setBackground(Color.blue);
}
repaint();
return true;
}
}