To convert from AWT to AFC, instances of java.awt.CheckboxGroup should be transformed into instances of com.ms.ui.UIRadioGroup.
UIRadioGroup is a replacement for CheckboxGroup. One advantage, though, is that instead of just adding checkboxes (which are created with text items only), you can add components, so items in a UIRadioGroup could be represented by images, panels, and even other checkbuttons.
UIRadioGroups are built differently than CheckboxGroups. In AWT's CheckboxGroup, you could associate a checkbox with a particular UIRadioGroup by calling setCheckboxGroup(). In AFC, though, you create a UIRadioGroup and add components or strings to it. The add() method also returns the new UIRadioButton. This could look like
UIRadioGroup rg = new
UIRadioGroup("Colors");
UIRadioButton c1 = rg.add("red");
UIText c2 = new UIText("blue");
rg.add(c2);
You can specify the header of a UIRadioGroup by declaring it in the constructor, like
new UIRadioGroup(new UICanvas())
or
new UIRadioGroup("Title");
You could also call the setHeader() method.
This is the set of changes you need to make to port all CheckboxGroup methods to UIRadioGroup methods. Any method not listed here or below does not need to be changed.
AWT Code | AFC Code | Comments |
setCurrent(Checkbox) | (UIRadioButton).setChecked(true); | Deprecated in AWT 1.1 |
setSelectedCheckbox(Checkbox) | (UIRadioButton).setChecked(true); | Deprecated in AWT 1.1 |
Some methods in java.awt.CheckboxGroup are not directly supported in com.ms.ui.UIRadioGroup. Those methods are described here.
AWT Code | Comments |
getCurrent() getSelectedCheckbox() |
UIRadioButton does not support getting the selected checkbox from the group: instead, you need to use normal event handling to find it. getCurrent() is Deprecated in AWT 1.1. |