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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询