}
@Override
protected void setup() {
// Create the embedded.
final Embedded embedded = new Embedded();
embedded.setDescription("Click on the grid cells to switch them.");
addComponent(embedded);
// Attach it to a resource.
final MyImageSource imageSource = new MyImageSource();
final StreamResource imageResource = new StreamResource(imageSource,
"testimage.png");
imageResource.setCacheTime(0);
embedded.setSource(imageResource);
// The button requests repainting the embedded.
Button button = new Button("refr");
button.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
embedded.markAsDirty();
}
});
addComponent(button);
button = new Button("refr name");
button.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
((StreamResource) embedded.getSource()).setFilename(new Date()
.getTime() + ".png");
embedded.markAsDirty();
}
});
addComponent(button);
button = new Button("200x200");
button.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
embedded.setWidth("200px");
embedded.setHeight("200px");
}
});
addComponent(button);
button = new Button("undef");
button.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
embedded.setSizeUndefined();
}
});
addComponent(button);
}