how can I clear current selection from a radio button group?
Let's say I have three radio buttons, A, B, and C and that A is selected. All three are part of a button group.
I would like to clear A's selection status so that none of the radio buttons are selected. Oddly enough, A.setSelected(false);
does not seem to work [for radio buttons?].
What am I doing wrong / how can I clear the selection status for a radio button?
Thanks.
No.A is already selected, either programmattically or by the user.I want to clear the current selection and set neither A, B, or C to be selected.setSelected(false) will not un-select my radio button(s)
i did think of another approach, i added a fourth button D to the button group, a button that is not visible to the user. if i want to clear the current selections, i select D.not ideal, but it works.
Usually it is a Bad Thing to clear the selection of a group of radio buttons.
To be consistent with the standard GUI usage, there should always be one and only one item selected. You should therefore create the radio button group with the default option selected.
Having a radio button group with no item selected will confuse the user. You might want to rethink about your design instead, e.g. using checkboxes.
Message was edited by: java_knight
> Having a radio button group with no item selected
> will confuse the user. You might want to rethink
> about your design instead, e.g. using checkboxes.
Or, depending on your situation, making the D button that zredbaron suggested, visible and labelling it "None" or something similar. In some situations I imagine it wouldn't be a poor solution.
I agree, we're all used to a radio button group enforcing one button is checked at any time, so you should have good arguments to deviate from this habit.
OleVVa at 2007-7-14 20:56:15 >

The jse6 clearSelection() makes perfect sense to me, as we are able to create the button group with none selected in the first place.
All I would want is some way to get my input form back to its original state (maybe from some sort of Undo button). Seems crazy all the stuff that has to be done before 1.6.