XCheckbox checkB = new XCheckbox("Green", "Green");
XCheckbox checkC = new XCheckbox("Blue", "Blue");
final XCheckboxGroup groupHorizontal = new XCheckboxGroup(false);
groupHorizontal.add(checkA, checkB, checkC);
final XLabel label1 = new XLabel("Favorite color", XLabelType.Header);
final XLabel label2 = new XLabel("Favorite color", XLabelType.Header);
panel.addWidgets(label2, groupHorizontal, label1, groupVertical, new HTML(" "));
check0.setValue(true);
check1.setValue(true);
checkA.setValue(true);
checkC.setValue(true);
groupVertical.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionChangedEvent e) {
String s = "Favorite color: ";
for (XCheckbox c : groupVertical.getCheckedWidgets()) {
s += c.getName() + ", ";
}
label1.setText(s);
}
});
groupHorizontal.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionChangedEvent e) {
String s = "Favorite color: ";
for (XCheckbox c : groupHorizontal.getCheckedWidgets()) {
s += c.getName() + ", ";
}
label2.setText(s);
}
});
return panel;
}