Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6251051

It is not possible to unselect a JRadioButton witch is part of a ButtonGroup

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2, 5.0
    • client-libs
    • x86
    • linux, windows_2000

      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

            shickeysunw Shannon Hickey (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: