Pergunta

I have a program which prompts users to select a choice out of four options (from a group of RadioButtons).

Once the user has made a choice, he/she clicks a button and then receives a message. After closing the window, the user will go back to the first window and make a new selection if desired. What I want is for the radiobuttons to be totally clear.

So far I have implemented a method to actually unselect the radiobuttons and works well (clears the values of the variables), what it doesn't do is to remove the black spot from the previously selected radiobutton. In the other hand this same method works fine with unselecting and unchecking checkboxes.

Any tip to fix this little issue?

Here's my code:

public void clean() {
    jRadioButton1.setSelected(false);
    jRadioButton2.setSelected(false);
    jRadioButton3.setSelected(false);
    jRadioButton4.setSelected(false);
    jCheckBox1.setSelected(false);
    jCheckBox2.setSelected(false);
}
Foi útil?

Solução

make them group of buttons and then buttonGroup1.clearSelection();

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top