Pasos:
1. Creamos un proyecto Web.
2. En el diseñador agregamos un checkbox y dos botones.
![]() |
![]() |
Generando automáticamente
private Checkbox checkbox1 = new Checkbox();
public Checkbox getCheckbox1() {
return checkbox1;
}
public void setCheckbox1(Checkbox c) {
this.checkbox1 = c;
}
3.Damos click derecho en el botón Habilitar, y seleccionamos Edit Action Event Handler.
![]() |
A continuación, agregamos el código: this.checkbox1.setSelected(true);, el método setSelected con valor true, marca el checkbox como seleccionado, y un valor de false, quita la marca.
public String button1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
this.checkbox1.setSelected(true);
return null;
}
4. Agregar el código al botón deshabilitar
public String button2_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
this.checkbox1.setSelected(false);
return null;
}
![]() |
![]() |
| action.png | ![]() |
12888 bytes |
| binding.png | ![]() |
36214 bytes |
| boton1.png | ![]() |
7041 bytes |
| boton2.png | ![]() |
6538 bytes |
| page1.png | ![]() |
28600 bytes |