如何使用 if 语句检查我的 jradio 按钮是否被选中
how to check my jradio button is selected or not using if statement
if (radioButton.isSelected())
{
//do something
}
如何使用 if 语句检查我的 jradio 按钮是否被选中...这里的 "isSelected" 是什么?抱歉,我是新手... tq
JRadioButton 从 class javax.swing.AbstractButton 继承 isSelected 方法
下面说明了它的工作原理:-
public boolean isSelected()
Returns the state of the button. True if
the toggle button is selected, false if it's not.
使用isSelected
方法:
void setSelected(boolean)
boolean isSelected()
Set or get whether the button is selected. Makes sense only for buttons that have on/off state, such as check boxes.
示例:
if (radioButton.isSelected()) {
doThis();
}else{
doThat();
}
您可以参考更多信息here
你可以通过这段代码查看radioButton是否被选中
if (radioButton.isSelected()) {
//do something
}else {
//do something
}
"isSelected()" 是一个布尔函数,用于检查是否选择了组件如果选择了组件 returns true,如果未选择 returns false
更多:https://docs.oracle.com/javase/8/docs/api/javax/swing/AbstractButton.html#isSelected--
if (radioButton.isSelected())
{
//do something
}
如何使用 if 语句检查我的 jradio 按钮是否被选中...这里的 "isSelected" 是什么?抱歉,我是新手... tq
JRadioButton 从 class javax.swing.AbstractButton 继承 isSelected 方法 下面说明了它的工作原理:-
public boolean isSelected()
Returns the state of the button. True if the toggle button is selected, false if it's not.
使用isSelected
方法:
void setSelected(boolean) boolean isSelected() Set or get whether the button is selected. Makes sense only for buttons that have on/off state, such as check boxes.
示例:
if (radioButton.isSelected()) {
doThis();
}else{
doThat();
}
您可以参考更多信息here
你可以通过这段代码查看radioButton是否被选中
if (radioButton.isSelected()) {
//do something
}else {
//do something
}
"isSelected()" 是一个布尔函数,用于检查是否选择了组件如果选择了组件 returns true,如果未选择 returns false
更多:https://docs.oracle.com/javase/8/docs/api/javax/swing/AbstractButton.html#isSelected--