From a0b5ddf5d1c2b2cc5e7a9a2edd7fc86918c61edf Mon Sep 17 00:00:00 2001 From: Jani Laakso Date: Wed, 4 Apr 2007 08:04:04 +0000 Subject: [PATCH] svn changeset:1127/svn branch:trunk --- .../toolkit/demo/ObjectPropertyDemo.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/com/itmill/toolkit/demo/ObjectPropertyDemo.java b/src/com/itmill/toolkit/demo/ObjectPropertyDemo.java index fc6836ab0d..59b0ff0492 100644 --- a/src/com/itmill/toolkit/demo/ObjectPropertyDemo.java +++ b/src/com/itmill/toolkit/demo/ObjectPropertyDemo.java @@ -5,11 +5,13 @@ import com.itmill.toolkit.ui.*; public class ObjectPropertyDemo extends com.itmill.toolkit.Application { - private TextField textField = null; + private TextField floatTextField = null; + + private Label floatLabel = new Label(); - private Float floatValue = new Float(1.0f); + private Float floatObject = new Float(1.0f); - private ObjectProperty ob = null; + private ObjectProperty floatObjectProperty = null; private Button storeButton = new Button("Set", this, "storeButtonClickedEvent"); @@ -27,20 +29,23 @@ public class ObjectPropertyDemo extends com.itmill.toolkit.Application { setTheme("corporate"); - // Textfield - ob = new ObjectProperty(floatValue); - textField = new TextField("Textfield that uses ObjectProperty", ob); - ob.setReadOnly(false); + // Textfield that uses ObjectProperty + floatObjectProperty = new ObjectProperty(floatObject); + floatTextField = new TextField("floatTextField (uses ObjectProperty)", floatObjectProperty); + floatObjectProperty.setReadOnly(false); // needed because of bug in variable change handling? // change textfield value and unfocus it to change textfields value // succesfully - textField.setImmediate(true); - textField.setInvalidCommitted(true); + floatTextField.setImmediate(true); + floatTextField.setInvalidCommitted(true); + + floatLabel.setCaption("floatObject value"); - main.addComponent(textField); + main.addComponent(floatTextField); main.addComponent(storeButton); main.addComponent(commitButton); main.addComponent(discardButton); + main.addComponent(floatLabel); } public void storeButtonClickedEvent() { @@ -48,18 +53,19 @@ public class ObjectPropertyDemo extends com.itmill.toolkit.Application { } public void commitButtonClickedEvent() { - textField.commit(); + floatTextField.commit(); printValues(); } public void discardButtonClickedEvent() { - textField.discard(); + floatTextField.discard(); printValues(); } private void printValues() { - System.out.println("textField.getValue()=" + textField.getValue()); - System.out.println("floatValue=" + floatValue); + System.out.println("textField.getValue()=" + floatTextField.getValue()); + System.out.println("floatValue=" + floatObject); + floatLabel.setValue(floatObject); } } -- 2.39.5