aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java
diff options
context:
space:
mode:
authorcaalador <mikael.grankvist@gmail.com>2017-01-27 09:12:03 +0200
committerGitHub <noreply@github.com>2017-01-27 09:12:03 +0200
commit8be086b6cbabda2a65b3b970526ed3a69670b04c (patch)
tree71d57b6122eef0cac2506a586633625e9c14661a /server/src/main/java
parenta1cc08d7b98b09e45a01bde6abe13ffdcb200598 (diff)
downloadvaadin-framework-8be086b6cbabda2a65b3b970526ed3a69670b04c.tar.gz
vaadin-framework-8be086b6cbabda2a65b3b970526ed3a69670b04c.zip
Add convenience constructors for TextField (#597) (#8341)
Add convenience constructors for TextField (#597) Added TextField convenience constructors similar to the ones found in Vaadin framework 7
Diffstat (limited to 'server/src/main/java')
-rw-r--r--server/src/main/java/com/vaadin/ui/TextField.java51
1 files changed, 50 insertions, 1 deletions
diff --git a/server/src/main/java/com/vaadin/ui/TextField.java b/server/src/main/java/com/vaadin/ui/TextField.java
index 3969fec202..a8171ba4f4 100644
--- a/server/src/main/java/com/vaadin/ui/TextField.java
+++ b/server/src/main/java/com/vaadin/ui/TextField.java
@@ -57,13 +57,62 @@ public class TextField extends AbstractTextField {
* @param caption
* the caption <code>String</code> for the editor.
* @param value
- * the initial text content of the editor.
+ * the initial text content of the editor, not {@code null}
*/
public TextField(String caption, String value) {
setValue(value);
setCaption(caption);
}
+ /**
+ * Constructs a new {@code TextField} with a value change listener. The
+ * listener is called when the value of this {@code TextField} is changed
+ * either by the user or programmatically.
+ *
+ * @param valueChangeListener
+ * the value change listener, not {@code null}
+ */
+ public TextField(ValueChangeListener valueChangeListener) {
+ addValueChangeListener(valueChangeListener);
+ }
+
+ /**
+ * Constructs a new {@code TextField} with the given caption and a value
+ * change listener.
+ * <p>
+ * The listener is called when the value of this {@code TextField} is
+ * changed either by the user or programmatically.
+ *
+ * @param caption
+ * the caption {@code String} for the editor.
+ * @param valueChangeListener
+ * the value change listener, not {@code null}
+ */
+ public TextField(String caption, ValueChangeListener valueChangeListener) {
+ this(valueChangeListener);
+ setCaption(caption);
+ }
+
+ /**
+ * Constructs a new {@code TextField} with the given caption, initial text
+ * contents and a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code TextField} is
+ * changed either by the user or programmatically.
+ *
+ * @param caption
+ * the caption {@code String} for the editor.
+ * @param value
+ * the initial text content of the editor, not {@code null}
+ * @param valueChangeListener
+ * the value change listener, not {@code null}
+ */
+ public TextField(String caption, String value,
+ ValueChangeListener valueChangeListener) {
+ this(caption, value);
+ addValueChangeListener(valueChangeListener);
+ }
+
@Override
protected TextFieldState getState() {
return (TextFieldState) super.getState();