-
Bug
-
Resolution: Fixed
-
P4
-
1.1.6, 1.2.0
-
mantis
-
sparc
-
solaris_2.5
Name: dsC58869 Date: 05/08/98
The method java.awt.Checkbox.setCheckboxGroup(CheckboxGroup checkboxGroup)
called by selected Checkbox works wrong when checkboxGroup already has
selected checkbox. In this case both checkboxes get selected (true) status.
==== Here is the test demonstrating the bug ====
import java.awt.*;
public class Checkbox0001 {
public static void main(String[] args) {
CheckboxGroup gr = new CheckboxGroup();
Checkbox chb1 = new Checkbox("Box 1", true, gr);
Checkbox chb2 = new Checkbox("Box 2", true, null);
chb2.setCheckboxGroup(gr);
System.out.println(chb1.getState());
System.out.println(chb2.getState());
System.out.println(chb1.getCheckboxGroup());
System.out.println(chb2.getCheckboxGroup());
System.out.println(gr.getSelectedCheckbox());
if(!chb1.getState() && chb2.getState()
&& chb1.getCheckboxGroup() == gr && chb2.getCheckboxGroup() == gr
&& gr.getSelectedCheckbox() == chb2)
System.out.println("OKAY");
else System.out.println("failed");
}
}
==== Here is the output of the test ====
%java Checkbox0001
true
true
java.awt.CheckboxGroup[selectedCheckbox=java.awt.Checkbox[,0,0,0x0,invalid,label=Box 1,state=true]]
java.awt.CheckboxGroup[selectedCheckbox=java.awt.Checkbox[,0,0,0x0,invalid,label=Box 1,state=true]]
java.awt.Checkbox[,0,0,0x0,invalid,label=Box 1,state=true]
failed
^C
======================================================================
Justification:
The method should work properly constructor Checkbox(String, boolean, ChechboxGroup)
======================================================================