diff options
Diffstat (limited to 'vaadin-app/src/ch/asynk/helloworld')
-rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java | 33 |
1 files 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(), "<i>italic</i> <b>bold</b> description",Window.Notification.TYPE_WARNING_MESSAGE); + getApplication().getMainWindow().showNotification("The time is " + new Date(), "<i>italic</i> <b>bold</b> 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"); } |