summaryrefslogtreecommitdiffstats
path: root/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java
blob: e0d0b6b5d282eb342fd7edcb76b094aacad35638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package ch.asynk.helloworld;

import java.util.Date;

import com.vaadin.Application;
import com.vaadin.terminal.UserError;
import com.vaadin.ui.Window;
import com.vaadin.ui.Label;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;


public class HelloWorldApp extends Application {

	private static final long serialVersionUID = 1L;

	@Override
	public void init() {
        final Window mainWindow = new Window("Hello World Application");
        Label label = new Label("Hello world");
        mainWindow.addComponent(label);
        //
        mainWindow.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);
                event.getButton().setComponentError( new UserError("Stop pressing this button !!") );
            }
        }));
        //
        Button closeButton = new Button("close the application");
        mainWindow.addComponent(closeButton );
        closeButton.addListener( new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                getMainWindow().getApplication().close();
            }
        });
        //
        setMainWindow(mainWindow);
        setLogoutURL("http://asynk.ch");
	}
}