java JCheckBox 知道复选框是否被选中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10527736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JCheckBox knowing if checkbox is selected or not
提问by The JAVA Noob
To set a JCheckBox is using setSelected method with a boolean condition. Which method do i use to get the boolean data out of the JCheckBox. Thanks
设置 JCheckBox 是使用带有布尔条件的 setSelected 方法。我使用哪种方法从 JCheckBox 中获取布尔数据。谢谢
回答by COD3BOY
Did you mean to check if the JCheckbox is selected? if so use isSelected()
你的意思是检查 JCheckbox 是否被选中?如果是这样,请使用isSelected()
You can also use an ItemListenerin case you want to get notified about the check and uncheck!
如果您想收到有关选中和取消选中的通知,您还可以使用ItemListener!
回答by Anuj Balan
回答by nIcE cOw
isSelected()is the method you looking for, I guess. This will return false
if JCheckBox
is NOT Selected
and true
if Selected
.
isSelected()是你要找的方法,我猜。这将返回false
if JCheckBox
isNOT Selected
和true
if Selected
。