XRadioButton radio0 = new XRadioButton("Red", "Red");
XRadioButton radio1 = new XRadioButton("Green", "Green");
XRadioButton radio2 = new XRadioButton("Blue", "Blue");
final XRadioButtonGroup group1 = new XRadioButtonGroup(true);
group1.add(radio0, radio1, radio2);
XRadioButton radioA = new XRadioButton("Red", "Red");
XRadioButton radioB = new XRadioButton("Green", "Green");
XRadioButton radioC = new XRadioButton("Blue", "Blue");
final XRadioButtonGroup group2 = new XRadioButtonGroup(false);
group2.add(radioA, radioB, radioC);
final XLabel label1 = new XLabel("Favorite color", XLabelType.Header);
final XLabel label2 = new XLabel("Favorite color", XLabelType.Header);
radio0.setValue(true);
radioA.setValue(true);
group1.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionChangedEvent e) {
label1.setText("Favorite color: " + group1.getCheckedWidget().getName());
}
});
group2.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionChangedEvent e) {
label2.setText("Favorite color: " + group2.getCheckedWidget().getName());
}
});
panel.addWidgets(label2, group2, label1, group1, new HTML(" "));