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(), "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 );
closeButton.addListener( new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getMainWindow().getApplication().close();
}
});
//
setMainWindow(mainWindow);
setLogoutURL("http://asynk.ch");
}
}