From d7f316ef205ac5617bd9ac6473ee6a1f563896c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 26 Sep 2011 10:44:41 +0200 Subject: vaadin-app: use Property.ValueChangeListener --- .../src/ch/asynk/helloworld/HelloWorldApp.java | 44 +++++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java index 9a4ecf0..8abd99d 100644 --- a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java +++ b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java @@ -4,11 +4,45 @@ import java.util.Date; import com.vaadin.Application; import com.vaadin.terminal.UserError; +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.ui.FormLayout; 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; +import com.vaadin.ui.TextField; + +class DataMappingLayout extends FormLayout { + + public DataMappingLayout() { + // + final TextField tf1 = new TextField("Property.ValueChangeListener"); + tf1.setImmediate(true); + addComponent(tf1); + final Label lb1 = new Label(); + lb1.setCaption("The Value"); + addComponent(lb1); + tf1.addListener( new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + String value = (String) tf1.getValue(); + lb1.setValue(value); + } + }); + // + Button closeButton = new Button("close the application"); + closeButton.setDescription("This will close the application"); + addComponent(closeButton ); + closeButton.addListener( new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + getApplication().getMainWindow().getApplication().close(); + } + }); + } +} class MainLayout extends VerticalLayout { @@ -24,13 +58,13 @@ class MainLayout extends VerticalLayout { } })); // - Button closeButton = new Button("close the application"); - closeButton.setDescription("This will close the application"); - addComponent(closeButton ); - closeButton.addListener( new Button.ClickListener() { + 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().getApplication().close(); + getApplication().getMainWindow().setContent( new DataMappingLayout() ); } }); } -- cgit v1.1-2-g2b99