import java.awt.*;
public class CheckboxTest {
    static Frame frm=new Frame("CheckboxTest");
 
     static Checkbox che1=new Checkbox("A",true);
     static Checkbox che2=new Checkbox("B",false);
     static Checkbox che3=new Checkbox("C",true);
     static Checkbox che4=new Checkbox("D");
     static Checkbox che5=new Checkbox("E");
public static void main(String[] args) {
frm.setSize(200,150);
frm.setLayout(null);
frm.setBackground(Color.pink);
che1.setBounds(20,40,140,20);
che2.setBounds(20,40,140,20);
che3.setBounds(20,40,140,20);
che4.setBounds(20,40,140,20);
che5.setBounds(20,40,140,20);
che4.setState(true);
frm.add(che1);
frm.add(che2);
frm.add(che3);
frm.add(che4);
frm.add(che5);
frm.setVisible(true);


}
}

解决方案 »

  1.   

    运行了一下,只出现了checkbox che1.
      

  2.   

    哦,这个没想到。import   java.awt.*;
    public   class   CheckboxTest   {
            static   Frame   frm=new   Frame("CheckboxTest");
            static   Checkbox   che1=new   Checkbox("A",true);
            static   Checkbox   che2=new   Checkbox("B",false);
            static   Checkbox   che3=new   Checkbox("C",true);
            static   Checkbox   che4=new   Checkbox("D");
            static   Checkbox   che5=new   Checkbox("E");
    public   static   void   main(String[]  args)   {
    frm.setSize(200,150);
    frm.setLayout(null);
    frm.setBackground(Color.pink);
    che1.setBounds(20,30,140,20);
    che2.setBounds(20,50,140,20);
    che3.setBounds(20,70,140,20);
    che4.setBounds(20,90,140,20);
    che5.setBounds(20,110,140,20);
    che4.setState(true);
    frm.add(che1);
    frm.add(che2);
    frm.add(che3);
    frm.add(che4);
    frm.add(che5);
    frm.setVisible(true);
    }
    }