import java.awt.*;
import java.awt.event.*;
class CheckboxExample extends WindowAdapter implements ItemListener{
Frame f;
Panel p;
Checkbox one,twe, three;
TextField tf;
public static void main(String args[]){
CheckboxExample ce=new CheckboxExample();
ce.go();
}
public void go(){
f=new Frame("Checkbox Example");
p=new Panel();
one=new Checkbox("one");
two=new Checkbox("two");
three=new checkbox("three");
one.addItemListener(this);
two.addItemListener(this);
three.addItemListener(this);
p.add(one);
p.add(two);
p.add(three);
f.add(p,"Center");
tf=new TextField();
f.add(tf,"South");
f.addWindowListener(this);
f.setSize(300,500);
f.setVisible(true);
}
public void itemStateChanged(ItemEvent e){
String state="deselected";
String st;
if(e.getStateChange()==ItemEvent.SELECTED){
state="selected";
}
st=e.getItem()+""+state;
tf.setText(st);
}
public void windowClosing(WindowEvent e){
System.exit(0);
}
}