protected void setup() {
HorizontalLayout buttonLayout = new HorizontalLayout();
addComponent(buttonLayout);
Button page1 = new Button("Hello World");
buttonLayout.addComponent(page1);
Button page2 = new Button("Lorem ipsum");
buttonLayout.addComponent(page2);
Button page3 = new Button("null");
buttonLayout.addComponent(page3);
final BrowserFrame browser = new BrowserFrame();
browser.setId("browser");
browser.setWidth("600px");
browser.setHeight("300px");
browser.setAlternateText("Browser alternative text");
final TextSource textSource = new TextSource("initial");
final StreamResource textResource = new StreamResource(textSource,
"initial.txt");
textResource.setMIMEType("text/plain");
browser.setSource(textResource);
addComponent(browser);
page1.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
TextSource helloSource = new TextSource("Hello World");
StreamResource helloResource = new StreamResource(helloSource,
"helloworld.txt");
helloResource.setMIMEType("text/plain");
browser.setSource(helloResource);
}
});
page2.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
TextSource helloSource = new TextSource("Lorem Ipsum");
StreamResource helloResource = new StreamResource(helloSource,
"loremipsum.txt");
helloResource.setMIMEType("text/plain");
browser.setSource(helloResource);
}
});
page3.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
browser.setSource(null);
}