//声名两单选按钮
private JRadioButton male;
private JRadioButton female;
//初始化按钮男默认选
male = new JRadioButton("男", true);
female = new JRadioButton("女");
//两按钮放同组
ButtonGroup group = new ButtonGroup();
group.add(male);
group.add(female);
//actionPerformed(...)获得按钮选择值
DefaultButtonModel model = (DefaultButtonModel) male.getModel();
if (model.getGroup().isSelected(model))
//男被选处理
else
//女被选处理