Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uncheck checkboxes in java

Tags:

java

jcheckbox

In my program, I want to uncheck all the checkboxes whenever this method is called. Can someone explain why it isn't working? Whenever I call this method the checkboxes are still selected.

private void nextQuestionButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                   

     clearOptions();

}    

public void clearOptions ()   
{ 
    //Make sure the check boxes are not checked
    optionA.setSelected(false);
    optionB.setSelected(false);
    optionC.setSelected(false);
    optionD.setSelected(false);  
}
like image 603
user2175095 Avatar asked Mar 25 '13 16:03

user2175095


1 Answers

first of all you need to bring all of the check box s code on the top of your for example state change method & after that for uncheck the check box you can make a variable like state & put the variable value on false & after that you can call the checkbox.setSelected(false); or boolean state = false; CheckBox.setSelected(state);that's it !!!

like image 128
Ahuramazda Avatar answered Nov 03 '22 00:11

Ahuramazda