Svoklavok :
I have a swing GUI, I'm trying to get my GUI to close if a certain requirement is met only if the checkbox is checked
JCheckBox C1 = new JCheckBox("checkbox 1");
so the code should be something like
if(Jcheckbox is pressed) //do something
if that makes sense
am0awad :
Try this:
if(c1.isSelected()){
// your code
}
or use event if you want to do some action when the selection happens
myCheckBox.addItemListener((ItemEvent e) {
if(e.getStateChange() == ItemEvent.SELECTED) {
//do something...
} else {//checkbox has been deselected
//do something...
}
}
});
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=344552&siteId=1