|
Clicking on a check box will change its state. The state is the // A check box with default state (not checked, false).
final CheckBox checkbox1 = new CheckBox("My CheckBox");
main.addComponent(checkbox1);
// Another check box with explicitly set checked state.
final CheckBox checkbox2 = new CheckBox("Checked CheckBox");
checkbox2.setValue(true);
main.addComponent(checkbox2);
// Make some application logic. We use anonymous listener
// classes here. The above references were defined as final
// to allow accessing them from inside anonymous classes.
checkbox1.addListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
// Copy the value to the other checkbox.
checkbox2.setValue(checkbox1.getValue());
}
});
checkbox2.addListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
// Copy the value to the other checkbox.
checkbox1.setValue(checkbox2.getValue());
}
}); For an example on the use of check boxes in a table, see Section 5.12, “ |
Table of Contents
|