swing 选项框(遍历选中的)

来源:互联网 发布:win10要求输入网络凭证 编辑:程序博客网 时间:2024/03/29 00:33


public String OdsSystem;


private void jbt_executeActionPerformed(java.awt.event.ActionEvent evt) {


//select OdsSystem
if (this.jrb_crm.isSelected()) {
OdsSystem = "CRM";
}


if (this.jrb_cbs.isSelected()) {
OdsSystem = "CBS";
}


if (this.jrb_sps.isSelected()) {
OdsSystem = "SPS";
}


if (StringUtil.isEmpty(OdsSystem)){
JOptionPane.showMessageDialog(null, "请选择系统!");
return;
}


//select OdsCity
int n=this.jPanel1.getComponentCount();
int m=0;//选中一个地市,计数器m自加1
for (int i = 0; i < n; i++) {
if(((JCheckBox) this.jPanel1.getComponent(i)).isSelected()){
System.out.println(OdsSystem + "_" +((JCheckBox) this.jPanel1.getComponent(i)).getText());
m++;
}
}

if (m==0){
JOptionPane.showMessageDialog(null, "请选择地市!");
return;
}



}
0 0