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

Checkbox.setCheckboxGroup(null) alters selection for CB's previous CBGroup

XMLWordPrintable

    • mantis
    • generic, sparc
    • solaris_2.5, solaris_2.6

      orig synopsis: "Checkbox.setCheckboxGroup() works wrong with null parameter"

      Name: dsC58869 Date: 02/23/98



      The method java.awt.Checkbox.setCheckboxGroup(CheckboxGroup checkboxGroup) works wrong
      with null parameter. Trying to remove this checkbox from checkboxGroup it sets all
      checkboxes in this checkboxGroup to be off. There is no reason to do this.

      ==== Here is the test demonstrating the bug ====
      import java.awt.*;

      public class Test{
          
          public static void main(String[] args){
      CheckboxGroup cbg = new CheckboxGroup();
      Checkbox chbox1 = new Checkbox("First", cbg, true);
      Checkbox chbox2 = new Checkbox("Second", cbg, false);

      System.out.println(cbg.getSelectedCheckbox());
      if(cbg.getSelectedCheckbox() != chbox1) {
      System.out.println("??????Failed??????");
      return;
      }
      chbox2.setCheckboxGroup(null);
      if(cbg.getSelectedCheckbox() != chbox1) {
      System.out.println("Failed: The selected checkbox was changed");
      System.out.println("The new selected checkbox: " + cbg.getSelectedCheckbox());
      return;
      }
      System.out.println("OKAY");
          }
      }

      ==== Here is the output of the test ====
      %java Test
      java.awt.Checkbox[checkbox0,0,0,0x0,invalid,label=First,state=true]
      Failed: The selected checkbox was changed
      The new selected checkbox: null
      ^C
      ======================================================================
       Justification:
      The method should work properly

      ======================================================================

            kdmsunw Kdm Kdm (Inactive)
            dsilaev Dmitri Silaev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: