문제

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);
}
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top