public void init() {
LegacyWindow mainWindow = new LegacyWindow("Helloworld Application");
VerticalLayout panelLayout = new VerticalLayout();
panelLayout.setMargin(true);
final Panel panel = new Panel("Test", panelLayout);
final Button button = new Button("ablebutton");
panelLayout.addComponent(button);
CheckBox enable = new CheckBox("Toggle button enabled", true);
enable.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
boolean enabled = (Boolean) event.getProperty().getValue();
button.setEnabled(enabled);
// button.requestRepaint();
}
});
enable.setImmediate(true);
CheckBox caption = new CheckBox("Toggle button caption", true);
caption.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
button.setCaption(button.getCaption() + "+");
}
});
caption.setImmediate(true);
CheckBox visible = new CheckBox("Toggle panel visibility", true);
visible.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
boolean visible = (Boolean) event.getProperty().getValue();
panel.setVisible(visible);
}
});
visible.setImmediate(true);
CheckBox panelEnable = new CheckBox("Toggle panel enabled", true);
panelEnable.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
boolean enabled = (Boolean) event.getProperty().getValue();
panel.setEnabled(enabled);
}
});
panelEnable.setImmediate(true);
mainWindow.addComponent(enable);