blob: 0aaea6c9cf48f340c926d03feef5f3a28a686834 (
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
44
45
46
47
48
49
|
package ch.asynk.helloworld;
import java.util.Date;
import com.vaadin.terminal.UserError;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Window.Notification;
public class MainLayout extends VerticalLayout {
private static final long serialVersionUID = 1L;
public MainLayout() {
Label label = new Label("Hello world");
addComponent(label);
//
addComponent( new Button("What is the time?", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getApplication().getMainWindow().showNotification("The time is " + new Date(), "<i>italic</i> <b>bold</b> description",Notification.TYPE_WARNING_MESSAGE);
event.getButton().setComponentError( new UserError("Stop pressing this button !!") );
}
}));
///
Button exceptionButton = new Button("throw an exception");
addComponent(exceptionButton );
exceptionButton.addListener( new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
throw new RuntimeException("Wahou !! : exception");
}
});
//
Button nextButton = new Button("next layout");
nextButton.setDescription("Go to next layout");
addComponent(nextButton );
nextButton.addListener( new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getApplication().getMainWindow().setContent( new DataMappingLayout() );
}
});
}
}
|