summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/ui/CheckBox.java
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2009-05-11 09:19:03 +0000
committerHenri Sara <henri.sara@itmill.com>2009-05-11 09:19:03 +0000
commitadc8c0ad3573272c236040c3a76005b9e73a5737 (patch)
treea3860704dbd5b82dc6af38684b80f8ef79a32722 /src/com/vaadin/ui/CheckBox.java
parent5abc870dda584d0c2fc47fd5eec4ae3de3fa240e (diff)
downloadvaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.tar.gz
vaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.zip
#2904: initial bulk rename "com.itmill.toolkit" -> "com.vaadin"
- com.itmill.toolkit.external not yet fully renamed svn changeset:7715/svn branch:6.0
Diffstat (limited to 'src/com/vaadin/ui/CheckBox.java')
-rw-r--r--src/com/vaadin/ui/CheckBox.java103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/com/vaadin/ui/CheckBox.java b/src/com/vaadin/ui/CheckBox.java
new file mode 100644
index 0000000000..32b47412a3
--- /dev/null
+++ b/src/com/vaadin/ui/CheckBox.java
@@ -0,0 +1,103 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.ui;
+
+import java.lang.reflect.Method;
+
+import com.vaadin.data.Property;
+
+@SuppressWarnings("serial")
+public class CheckBox extends Button {
+ /**
+ * Creates a new switch button.
+ */
+ public CheckBox() {
+ setSwitchMode(true);
+ }
+
+ /**
+ * Creates a new switch button with a caption and a set initial state.
+ *
+ * @param caption
+ * the caption of the switch button
+ * @param initialState
+ * the initial state of the switch button
+ */
+ public CheckBox(String caption, boolean initialState) {
+ super(caption, initialState);
+ }
+
+ /**
+ * Creates a new switch button with a caption and a click listener.
+ *
+ * @param caption
+ * the caption of the switch button
+ * @param listener
+ * the click listener
+ */
+ public CheckBox(String caption, ClickListener listener) {
+ super(caption, listener);
+ setSwitchMode(true);
+ }
+
+ /**
+ * Convenience method for creating a new switch button with a method
+ * listening button clicks. Using this method is discouraged because it
+ * cannot be checked during compilation. Use
+ * {@link #addListener(Class, Object, Method)} or
+ * {@link #addListener(com.vaadin.ui.Component.Listener)} instead.
+ * The method must have either no parameters, or only one parameter of
+ * Button.ClickEvent type.
+ *
+ * @param caption
+ * the Button caption.
+ * @param target
+ * the Object having the method for listening button clicks.
+ * @param methodName
+ * the name of the method in target object, that receives button
+ * click events.
+ */
+ public CheckBox(String caption, Object target, String methodName) {
+ super(caption, target, methodName);
+ setSwitchMode(true);
+ }
+
+ /**
+ * Creates a new switch button that is connected to a boolean property.
+ *
+ * @param state
+ * the Initial state of the switch-button.
+ * @param dataSource
+ */
+ public CheckBox(String caption, Property dataSource) {
+ super(caption, dataSource);
+ setSwitchMode(true);
+ }
+
+ /**
+ * Creates a new push button with a set caption.
+ *
+ * The value of the push button is always false and they are immediate by
+ * default.
+ *
+ * @param caption
+ * the Button caption.
+ */
+
+ public CheckBox(String caption) {
+ super(caption, false);
+ }
+
+ @Override
+ public void setSwitchMode(boolean switchMode)
+ throws UnsupportedOperationException {
+ if (this.switchMode && !switchMode) {
+ throw new UnsupportedOperationException(
+ "CheckBox is always in switch mode (consider using a Button)");
+ }
+ super.setSwitchMode(true);
+ }
+
+}