-
Bug
-
Resolution: Fixed
-
P4
-
1.2a, 1.2.0
-
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
======================================================================
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
======================================================================
- duplicates
-
JDK-4136498 Checkbox.setCheckboxGroup(CheckboxGroup) works wrong with null parameter
- Closed
- relates to
-
JDK-4726853 Checkbox is changing it's state after removing from CheckboxGroup
- Resolved