import java.applet.*;
import java.awt.*;
//import java.awt.event.*;
import java.util.Random;
//import java.awt.Color;
public class CheckBox extends Frame {
String msg = "";
Checkbox Red, Black, Magenta, Blue, Green, Yellow;
[COLOR="Red"]CheckboxGroup cbg[/COLOR]; // Creates an instance of a selector that makes sure only 1 button is pressed
Color theColor = Color.black;
public CheckBox( ) {
setLayout(new FlowLayout()); // this code creates 2 boxes.
cbg = new CheckboxGroup();
Red = new Checkbox("Red", [COLOR="Red"]cbg[/COLOR], true);
Black = new Checkbox("Black", cbg, true);
Magenta = new Checkbox("Magenta", cbg, true);
Blue = new Checkbox("Blue", cbg, true);
Green = new Checkbox("Green", cbg, true);
Yellow = new Checkbox("Yellow", cbg, true);
add(Red);
add(Black);
add(Magenta);
add(Blue);
add(Green);
add(Yellow);
}
public Color getCurrentColor(){
if(cbg.getCurrent()== Red)
theColor = Color.red;
if(cbg.getCurrent()== Black)
theColor = Color.black;
if(cbg.getCurrent()== Magenta)
theColor = Color.magenta;
if(cbg.getCurrent()== Blue)
theColor = Color.blue;
if(cbg.getCurrent()== Green)
theColor = Color.green;
if(cbg.getCurrent()== Yellow)
theColor = Color.yellow;
return theColor;
}
}