Hi Group, I have a button group. Within that, I am having 2 JRadioButtons. One of them is selected. On click of some JButton, i want to de-select that radio button. On handler of JButton i wrote, but it doesnt work. Does anyone has any remedy over this ?
At least one button in a ButtonGroupmust be selected. If you read the API for ButtonGroup it gives you this workaround...
Initially, all buttons in the group are unselected. Once any button is selected, one button is always selected in the group. There is no way to turn a button programmatically to "off", in order to clear the button group. To give the appearance of "none selected", add an invisible radio button to the group and then programmatically select that button to turn off all the displayed radio buttons. For example, a normal button with the label "none" could be wired to select the invisible radio button.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.