swing 单选框(互斥buttonGroup),设置默认值,获取值
2015-10-22 08:50
726 查看
单选框默认为男
this.jrb_man.setSelected(true);
组合框默认第一个
this.jcb_bookType.setSelectedIndex(0);
获取单选框的值
String sex="";
boolean b=true;
if(b==this.jrb_man.isSelected()&&this.jrb_female.isSelected()!=b){
sex="男";
}else if(b==this.jrb_female.isSelected()&&b!=this.jrb_man.isSelected()){
sex="女";
}else if(b==this.jrb_female.isSelected()&&b==this.jrb_man.isSelected()){
JOptionPane.showMessageDialog(null,"只能选择一个性别");
return;
}
------------------------
互斥单选框
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup1.add(jrb_crm);
buttonGroup1.add(jrb_cbs);
buttonGroup1.add(jrb_sps);
this.jrb_man.setSelected(true);
组合框默认第一个
this.jcb_bookType.setSelectedIndex(0);
获取单选框的值
String sex="";
boolean b=true;
if(b==this.jrb_man.isSelected()&&this.jrb_female.isSelected()!=b){
sex="男";
}else if(b==this.jrb_female.isSelected()&&b!=this.jrb_man.isSelected()){
sex="女";
}else if(b==this.jrb_female.isSelected()&&b==this.jrb_man.isSelected()){
JOptionPane.showMessageDialog(null,"只能选择一个性别");
return;
}
------------------------
互斥单选框
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup1.add(jrb_crm);
buttonGroup1.add(jrb_cbs);
buttonGroup1.add(jrb_sps);
相关文章推荐
- 黑马程序员-OC回顾-基础语法(二)
- c总结8 --- 二级指针使用三种模型之一(二级指针1)
- 关于java POI读取Excel2007流关不掉问题
- webview简单使用
- 单链表之检测链表是否有环并找出环的入口点
- fatal error C1083: Cannot open type library file: 'swpublished.tlb': No such file or directory 解决办法
- swing 填充表格(自动)
- eclipse 工程测试包
- Dubbo client can not supported string message
- 批量地导入本地的scholar.enw到endnote
- 10.21html 标签
- 判断一个小时之内是否重复发送了10次短信
- MQ中 amqsput : command not found的解决办法
- 内部api请求
- Android 如何直播RTMP流
- 打造高性能JAVA应用你需要知道的
- SkipList跳表基本原理
- swing 确认框和提示框
- FreeBSD目录结构
- python核心编程 9-10习题