import java.awt.*;
import javax.swing.*;
public class Chap23_4 {
static JFrame frm=new JFrame("Checkbox Class");
static Container cp=frm.getContentPane();
static JRadioButton rb1=new JRadioButton("数字摄影机");
static JRadioButton rb2=new JRadioButton("数位相机");
static JCheckBox ckb1=new JCheckBox("Sony",true);
static JCheckBox ckb2=new JCheckBox("Nikon",true);
static JCheckBox ckb3=new JCheckBox("Others");
public static void main(String args[]) { rb1.setBounds(10,20,90,20); rb2.setBounds(107,20,78,20); ckb1.setBounds(20,60,140,20); ckb2.setBounds(20,80,140,20); ckb3.setBounds(20,100,140,20); ButtonGroup bgroup=new ButtonGroup(); bgroup.add(rb1); bgroup.add(rb2); rb1.setSelected(true); cp.add(rb1); cp.add(rb2); cp.add(ckb1); cp.add(ckb2); cp.add(ckb3); cp.setLayout(null); cp.setBackground(Color.WHITE); frm.setSize(200, 160); frm.setVisible(true); } }