]> source.dussan.org Git - vaadin-framework.git/commitdiff
Updated test application for Button click mouse events to include checkboxes as well...
authorJohn Alhroos <john.ahlroos@itmill.com>
Tue, 26 Apr 2011 13:34:20 +0000 (13:34 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Tue, 26 Apr 2011 13:34:20 +0000 (13:34 +0000)
svn changeset:18470/svn branch:6.6

tests/src/com/vaadin/tests/components/button/ButtonMouseDetails.java

index 8f1509abb790083bd23f6b18b78b68a57cabac3c..6aa13ac9034878616186c260d86f2ca487766f57 100644 (file)
@@ -3,6 +3,7 @@ package com.vaadin.tests.components.button;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.Label;
 
 public class ButtonMouseDetails extends TestBase {
@@ -11,35 +12,45 @@ public class ButtonMouseDetails extends TestBase {
 
     private int clickCounter = 1;
 
-    @Override
-    protected void setup() {
+    private Button.ClickListener clickListener = new Button.ClickListener() {
 
-        Button button = new Button("CLICK ME!", new Button.ClickListener() {
-            public void buttonClick(ClickEvent event) {
-                StringBuilder str = new StringBuilder(out.getValue().toString());
-                str.append(clickCounter + ":\t");
+        @Override
+        public void buttonClick(ClickEvent event) {
+            StringBuilder str = new StringBuilder(out.getValue().toString());
+            str.append(clickCounter + ":\t");
 
-                // Modifier keys
-                str.append("ctrl=" + event.isCtrlKey() + ",\t");
-                str.append("alt=" + event.isAltKey() + ",\t");
-                str.append("meta=" + event.isMetaKey() + ",\t");
-                str.append("shift=" + event.isShiftKey() + ",\t");
+            // Modifier keys
+            str.append("ctrl=" + event.isCtrlKey() + ",\t");
+            str.append("alt=" + event.isAltKey() + ",\t");
+            str.append("meta=" + event.isMetaKey() + ",\t");
+            str.append("shift=" + event.isShiftKey() + ",\t");
 
-                // Coordinates
-                str.append("X=" + event.getRelativeX() + ",\t");
-                str.append("Y=" + event.getRelativeY() + ",\t");
-                str.append("clientX=" + event.getClientX() + ",\t");
-                str.append("clientY=" + event.getClientY());
+            // Coordinates
+            str.append("X=" + event.getRelativeX() + ",\t");
+            str.append("Y=" + event.getRelativeY() + ",\t");
+            str.append("clientX=" + event.getClientX() + ",\t");
+            str.append("clientY=" + event.getClientY());
 
-                str.append("\n");
+            str.append("\n");
 
-                out.setValue(str.toString());
-                clickCounter++;
-            }
-        });
+            out.setValue(str.toString());
+            clickCounter++;
+        }
+    };
+
+    @Override
+    protected void setup() {
 
         getLayout().setSpacing(true);
+
+        Button button = new Button("CLICK ME!", clickListener);
+        button.setImmediate(true);
         addComponent(button);
+
+        CheckBox cb = new CheckBox("CHECK ME!", clickListener);
+        cb.setImmediate(true);
+        addComponent(cb);
+
         addComponent(out);
     }