aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2007-11-14 09:54:44 +0000
committerMarc Englund <marc.englund@itmill.com>2007-11-14 09:54:44 +0000
commit957bb1a8b415e6d72e07148d0b1ab1193f43aa41 (patch)
tree3931b13a10477ba2020f8a580e75ba83ab95e600 /src
parentb22d6f609961e376d46a2a69d8c760b69c8e7485 (diff)
downloadvaadin-framework-957bb1a8b415e6d72e07148d0b1ab1193f43aa41.tar.gz
vaadin-framework-957bb1a8b415e6d72e07148d0b1ab1193f43aa41.zip
Javadoc.
setSwitchMOde() throws. svn changeset:2803/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/ui/CheckBox.java121
1 files changed, 91 insertions, 30 deletions
diff --git a/src/com/itmill/toolkit/ui/CheckBox.java b/src/com/itmill/toolkit/ui/CheckBox.java
index da96a88989..6252a121d6 100644
--- a/src/com/itmill/toolkit/ui/CheckBox.java
+++ b/src/com/itmill/toolkit/ui/CheckBox.java
@@ -3,34 +3,95 @@ package com.itmill.toolkit.ui;
import com.itmill.toolkit.data.Property;
public class CheckBox extends Button {
- public CheckBox() {
- super();
- setSwitchMode(true);
- }
-
- public CheckBox(String caption, boolean initialState) {
- super(caption, initialState);
- setSwitchMode(true);
- }
-
- public CheckBox(String caption, ClickListener listener) {
- super(caption, listener);
- setSwitchMode(true);
- }
-
- public CheckBox(String caption, Object target, String methodName) {
- super(caption, target, methodName);
- setSwitchMode(true);
- }
-
- public CheckBox(String caption, Property dataSource) {
- super(caption, dataSource);
- setSwitchMode(true);
- }
-
- public CheckBox(String caption) {
- super(caption);
- setSwitchMode(true);
- }
-
+ /**
+ * 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) {
+ setCaption(caption);
+ setValue(new Boolean(initialState));
+ setSwitchMode(true);
+ }
+
+ /**
+ * 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) {
+ setCaption(caption);
+ addListener(listener);
+ setSwitchMode(true);
+ }
+
+ /**
+ * Creates a new switch button with a method listening button clicks. 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) {
+ setCaption(caption);
+ addListener(ClickEvent.class, 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) {
+ setCaption(caption);
+ setPropertyDataSource(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) {
+ setCaption(caption);
+ setSwitchMode(true);
+ }
+
+ public void setSwitchMode(boolean switchMode)
+ throws UnsupportedOperationException {
+ if (this.switchMode && !switchMode) {
+ throw new UnsupportedOperationException(
+ "CheckBox is always in switch mode (consider using a Button)");
+ }
+ this.switchMode = true;
+ }
+
}