JDK-6251051 : It is not possible to unselect a JRadioButton witch is part of a ButtonGroup
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2,5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux,windows_2000
  • CPU: x86
  • Submitted: 2005-04-05
  • Updated: 2010-04-02
  • Resolved: 2005-04-06
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
If some JRadioButton are part of a ButtonGroup and one of them is selected, it is not possible to unselect it.

JUSTIFICATION :
An application witch display a list of question could want to reset a form by unselecting all the radio button in the form.

Also, the application could want to radio buttons to be initially empty to be sure that the user answers all the questions voluntarily.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When calling radio.setSelected(true), the JRadioButton should be selected and all other in the group should be unselected (as it is doing right now).

When calling radio.setSelected(false), the JRadioButton should be unselected and NO other JRadioButton in the group should be selected (RFE).

ACTUAL -
When you call radio.setSelected(false) on a selected JRadioButton, nothing happens.

CUSTOMER SUBMITTED WORKAROUND :
You can create a subclass of ButtonGroup that create an invisible AbstractButton and when the selected AbstractButton is asked to be unselected, it simply select the hidden AbstractButton.

You could also subclass ButtonGroup and override the method setSelected(ButtonModel m, boolean b), but the member field "selection" in ButtonGroup is not visible to subclass. The field has no acess modifier (package protected). There is probably a reason, but is this limit the extension possibility of this class...
###@###.### 2005-04-05 22:44:18 GMT

Comments
EVALUATION Duplicate of 4066394. ###@###.### 2005-04-06 16:31:04 GMT
06-04-2005