⑴ java方法如何判斷多選框是夠勾選
js">javascript:
functiontest(){
varcb=document.getElementById('checkboxid');
if(cb.checked){
//TODOnormalwork...
}else{
alert('pleasecheckit');
return;
}
}
⑵ java中如何判斷是哪個單選框被選中了
上述使用有問題:
正確使用方法為:
CheckboxGroup cbg = new CheckboxGroup();
add(new Checkbox("one", cbg, true));
add(new Checkbox("two", cbg, false));
add(new Checkbox("three", cbg, false));
然後,像qsmy所述,使用:回
CheckboxGroup的方法:
Checkbox getSelectedCheckbox()
Gets the current choice from this check box group. 得到選擇的Checkbox。答
⑶ java中怎樣判斷復選框是否被選中
復選框 JCheckBox
中有個isSelected() 可以 判斷是否被選中
選中為true
反之則為false
⑷ java中怎麼知道單選框的選中狀態
使用JRadioButton定義選擇按鈕,如果要實現單選,需要把按鈕添加至ButtonGroup,如下:
ButtonGroup buttonGroup2 = new ButtonGroup();
JRadioButton select_ID = new JRadioButton();
JRadioButton select_Name = new JRadioButton();
JRadioButton select_Book = new JRadioButton();
JRadioButton select_All = new JRadioButton();
初始化時執行:回
buttonGroup2.add(select_ID);
答buttonGroup2.add(select_Book);
buttonGroup2.add(select_Name);
buttonGroup2.add(select_All);
判斷是否選中:
select_Name.isSelected() 選中時返回true,否則false