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.

[438 byte] By [zredbarona] at [2007-10-3 3:06:03]
# 1
Well,I think it should be like this:A.setSelected(true);If I am right,you wanna make A selected and all other false.
crazygala at 2007-7-14 20:56:15 > top of Java-index,Desktop,Core GUI APIs...
# 2
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)
zredbarona at 2007-7-14 20:56:15 > top of Java-index,Desktop,Core GUI APIs...
# 3
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.
zredbarona at 2007-7-14 20:56:15 > top of Java-index,Desktop,Core GUI APIs...
# 4
> not ideal, but it works. And if you search the forum you will find that that is the standard suggestion.
camickra at 2007-7-14 20:56:15 > top of Java-index,Desktop,Core GUI APIs...
# 5
Hello Hi i have a problem with clear the radio buttons ............can you suggest me how to clear radiobuttons in the group..........
Krsb83lpa at 2007-7-14 20:56:15 > top of Java-index,Desktop,Core GUI APIs...
# 6
it's already answered by reply 3.
j_shadinataa at 2007-7-14 20:56:15 > top of Java-index,Desktop,Core GUI APIs...
# 7
if you're using java 1.6, ButtonGroup now has a clearSelection()
Michael_Dunna at 2007-7-14 20:56:15 > top of Java-index,Desktop,Core GUI APIs...
# 8

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

java_knighta at 2007-7-14 20:56:15 > top of Java-index,Desktop,Core GUI APIs...
# 9

> 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 > top of Java-index,Desktop,Core GUI APIs...
# 10

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.

volbanda at 2007-7-14 20:56:15 > top of Java-index,Desktop,Core GUI APIs...