阅读更多
CheckBox check1 = new CheckBox();
check1.setBoxLabel("Brochures");
check1.setValueAttribute("Bro");
CheckBox check2 = new CheckBox();
check2.setBoxLabel("Events");
check2.setValue(true);
check2.setValueAttribute("Ev");
CheckBox check3 = new CheckBox();
check3.setBoxLabel("Announcements");
check3.setValue(true);
check3.setValueAttribute("Ann");
final CheckBoxGroup checkGroup = new CheckBoxGroup();
checkGroup.setFieldLabel("Subscribe");
checkGroup.add(check1);
checkGroup.add(check2);
checkGroup.add(check3);
fp.add(checkGroup);
Button click = new Button("click");
click.addSelectionListener(new SelectionListener() {
@Override
public void componentSelected(ButtonEvent ce) {
String info = "";
List values = checkGroup.getValues();
for (CheckBox checkBox : values) {
info += "
" + checkBox.getBoxLabel() + ": " + checkBox.getValueAttribute() + " " + checkBox.getValue();
}
MessageBox.alert("title", info, null);
}
});