aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2007-11-29 15:08:34 +0000
committerMarc Englund <marc.englund@itmill.com>2007-11-29 15:08:34 +0000
commitaa59c9adbf7886c97f7289e971fe04f2b9ce751f (patch)
tree9ff5e6f41456c1a1fd08d27f572dedaa33002e88 /src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java
parentf2e2e833db2b4b40a6332535f821956829820d6d (diff)
downloadvaadin-framework-aa59c9adbf7886c97f7289e971fe04f2b9ce751f.tar.gz
vaadin-framework-aa59c9adbf7886c97f7289e971fe04f2b9ce751f.zip
Added ComboBox example
svn changeset:3045/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java')
-rw-r--r--src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java b/src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java
new file mode 100644
index 0000000000..3c2da7d67e
--- /dev/null
+++ b/src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java
@@ -0,0 +1,55 @@
+package com.itmill.toolkit.demo.featurebrowser;
+
+import com.itmill.toolkit.ui.ComboBox;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.AbstractSelect.Filtering;
+
+/**
+ *
+ */
+public class ComboBoxExample extends CustomComponent {
+
+ private static final String[] firstnames = new String[] { "John", "Mary",
+ "Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Robert", "Paula",
+ "Lenny", "Kenny", "Nathan", "Nicole", "Laura", "Jos", "Josie",
+ "Linus" };
+
+ private static final String[] lastnames = new String[] { "Torvalds",
+ "Smith", "Adams", "Black", "Wilson", "Richards", "Thompson",
+ "McGoff", "Halas", "Jones", "Beck", "Sheridan", "Picard", "Hill",
+ "Fielding", "Einstein" };
+
+ public ComboBoxExample() {
+ OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ // starts-with filter
+ ComboBox s1 = new ComboBox("Select with starts-with filter");
+ s1.setColumns(20);
+ for (int i = 0; i < 105; i++) {
+ s1
+ .addItem(firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ + " "
+ + lastnames[(int) (Math.random() * (lastnames.length - 1))]);
+ }
+ s1.setImmediate(true);
+ main.addComponent(s1);
+
+ // contains filter
+ ComboBox s2 = new ComboBox("Select with contains filter");
+ s2.setColumns(20);
+ for (int i = 0; i < 500; i++) {
+ s2
+ .addItem(firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ + " "
+ + lastnames[(int) (Math.random() * (lastnames.length - 1))]);
+ }
+ s2.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS);
+ s2.setImmediate(true);
+ main.addComponent(s2);
+
+ }
+
+}