import java.awt.*;

public class RadioEvents extends Frame {
    private Button bttn;
    private CheckboxGroup cbg;
    private Checkbox red, blue, green;
    private Label  lblOne;
    private Label  lblTwo;
    
    public RadioEvents() { 
        super("Radio Events");
        this.setLayout(new GridLayout(9, 1));
        //Create Components
        lblOne = new Label("Select a radio button below.", Label.CENTER);
        lblTwo = new Label(" ", Label.CENTER);
        bttn = new Button("submit");
        cbg = new CheckboxGroup();
        red = new Checkbox("red", cbg, false);
        blue = new Checkbox("blue", cbg, true);
        green = new Checkbox("green", cbg, false);
       //Add Components
        this.add(lblOne);
        this.add(red);
        this.add(blue);
        this.add(green);
        this.add(bttn);
        this.add(lblTwo);
        //Show Frame
        this.resize(250, 250);
        this.move(150, 150);
        this.show();
    }

    public boolean action(Event e, Object arg) {
        if(e.target == bttn) {
            String temp = cbg.getCurrent().getLabel();
            lblTwo.setText("You want " + temp + ".");
            return true;
        }
        else return false;
    }

    public boolean handleEvent(Event e) {
        if (e.id==e.WINDOW_DESTROY) {
            dispose();
            System.exit(0);
            return true;
        }
        return super.handleEvent(e);
    }

    public static void main(String args[]) {
        new RadioEvents();
    }

}
