import java.awt.*; import java.awt.event.*; import java.lang.*; import java.lang.Math; public class Test1e extends java.applet.Applet { CheckboxGroup cbg; Checkbox Box0, Box1, Box2; Button Check; Label Response; public void init() { setBackground(new Color(200,200,200)); setLayout(new FlowLayout(FlowLayout.LEFT)); cbg = new CheckboxGroup(); Box0 = new Checkbox("is zero", cbg, true); add(Box0); Box1 = new Checkbox("is directed away from the outer sphere", cbg, false); add(Box1); Box2 = new Checkbox("is directed toward the outer sphere", cbg, false); add(Box2); // Check button Check = new Button("Check Answer"); add(Check); Response = new Label("Choose the answer you think is correct", Label.CENTER); add(Response); } public boolean action (Event evt, Object arg) { if (evt.target instanceof Button) { if (cbg.getCurrent().equals(Box1)) { Response.setText("Absolutely right!"); } else { Response.setText("Sorry, that's not correct."); } } else return super.action(evt, arg); return true; } }