From ac74040841dfafac499d6ac71579630d7415047c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 26 Sep 2011 10:42:04 +0200 Subject: vaadin-app: extend VerticalLayout --- .../src/ch/asynk/helloworld/HelloWorldApp.java | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java index 17deb07..9a4ecf0 100644 --- a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java +++ b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java @@ -4,40 +4,47 @@ import java.util.Date; import com.vaadin.Application; import com.vaadin.terminal.UserError; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.Label; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +class MainLayout extends VerticalLayout { -public class HelloWorldApp extends Application { - - private static final long serialVersionUID = 1L; - - @Override - public void init() { - final Window mainWindow = new Window("Hello World Application"); + public MainLayout() { Label label = new Label("Hello world"); - mainWindow.addComponent(label); + addComponent(label); // - mainWindow.addComponent( new Button("What is the time?", new Button.ClickListener() { + addComponent( new Button("What is the time?", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { - mainWindow.showNotification("The time is " + new Date(), "italic bold description",Window.Notification.TYPE_WARNING_MESSAGE); + getApplication().getMainWindow().showNotification("The time is " + new Date(), "italic bold description",Window.Notification.TYPE_WARNING_MESSAGE); event.getButton().setComponentError( new UserError("Stop pressing this button !!") ); } })); // Button closeButton = new Button("close the application"); closeButton.setDescription("This will close the application"); - mainWindow.addComponent(closeButton ); + addComponent(closeButton ); closeButton.addListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { - getMainWindow().getApplication().close(); + getApplication().getMainWindow().getApplication().close(); } }); - // + } + +} + +public class HelloWorldApp extends Application { + + private static final long serialVersionUID = 1L; + + @Override + public void init() { + final Window mainWindow = new Window("Hello World Application"); + mainWindow.setContent( new MainLayout() ); setMainWindow(mainWindow); setLogoutURL("http://asynk.ch"); } -- cgit v1.1-2-g2b99