首页 > 代码库 > single checkbox demo

single checkbox demo

package Gui;/** * check box must be in a same ButtonGroup can`t be selected  * at the same time *  * */import javax.swing.*;import java.awt.*;public class CheckBoxDemo extends JFrame{            public void launch(){            ButtonGroup bp = new ButtonGroup();            JCheckBox[] cb = new JCheckBox[10];            for(int i = 0 ;i<10;i++){                cb[i] = new JCheckBox("cb"+i);                bp.add(cb[i]);                add(cb[i]);            }                        setLayout(new FlowLayout());            setBounds(600,200,300,300);            setVisible(true);        }        public static void main(String[] args) {            CheckBoxDemo bbb = new CheckBoxDemo();            bbb.launch();                 }    }