aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxInputPromptExample.java
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2009-04-06 13:27:02 +0000
committerMarc Englund <marc.englund@itmill.com>2009-04-06 13:27:02 +0000
commitbdee6749d449ffdf7cf6584d9d67bca6f3d0dd79 (patch)
treea352b7570bd5888f30af6e1f260fdea87deb240c /src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxInputPromptExample.java
parentaa059edab19e8b10ebd18fb4c42b95c95dd60f49 (diff)
downloadvaadin-framework-bdee6749d449ffdf7cf6584d9d67bca6f3d0dd79.tar.gz
vaadin-framework-bdee6749d449ffdf7cf6584d9d67bca6f3d0dd79.zip
(merged from 5.4) Implements "input prompt" for ComboBox and TextField. Also includes Sampler samples. Fixes #1455
svn changeset:7337/svn branch:6.0
Diffstat (limited to 'src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxInputPromptExample.java')
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxInputPromptExample.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxInputPromptExample.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxInputPromptExample.java
new file mode 100644
index 0000000000..4146614659
--- /dev/null
+++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxInputPromptExample.java
@@ -0,0 +1,39 @@
+package com.itmill.toolkit.demo.sampler.features.selects;
+
+import com.itmill.toolkit.data.Property;
+import com.itmill.toolkit.data.Property.ValueChangeEvent;
+import com.itmill.toolkit.ui.ComboBox;
+import com.itmill.toolkit.ui.VerticalLayout;
+
+public class ComboBoxInputPromptExample extends VerticalLayout implements
+ Property.ValueChangeListener {
+
+ private static final String[] cities = new String[] { "Berlin", "Brussels",
+ "Helsinki", "Madrid", "Oslo", "Paris", "Stockholm" };
+
+ public ComboBoxInputPromptExample() {
+ setMargin(true); // for looks: more 'air'
+
+ // Create & set input prompt
+ ComboBox l = new ComboBox();
+ l.setInputPrompt("Please select a city");
+
+ // configure & load content
+ l.setImmediate(true);
+ l.addListener(this);
+ for (int i = 0; i < cities.length; i++) {
+ l.addItem(cities[i]);
+ }
+
+ // add to the layout
+ addComponent(l);
+ }
+
+ /*
+ * Shows a notification when a selection is made.
+ */
+ public void valueChange(ValueChangeEvent event) {
+ getWindow().showNotification("Selected city: " + event.getProperty());
+
+ }
+}