import java.awt.*;
import java.awt.event.*;
class CheckboxGroupExample extends WindowAdapter implements ItemListener{
Frame f;
Panel p;
CheckboxGroup cbg;
TextField tf;
public static void main (String [] args){
CheckboxGroupExample ce = new CheckboxGroupExample();
ce.go();
}
public void go(){
f = new Frame("CheckboxGroup Example");
p = new Panel();
cbg = new CheckboxGroup();
one = new Checkbox("One",cbg,false);
two = new Checkbox("Two",cbg,false);
three = new Checkbox("Three",cbg,true);
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();
tf.setText("Three selected");
f.add(tf,"South");
f.addWindowListener(this);
f.setSize(300,150);
f.setVisible(true);
}
public void itemStateChanged(ItemEvent e) {
String st;
st = e.getItem()+"selected";
tf.setText(st);
}
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
一个书上的上的程序我运行时出现找不到符号 one two three 的错误! 请各位高手帮我解答 谢谢!!!