com.vaadin.flow.component.textfield.
Class NumberField
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.AbstractField<C,T>
-
- com.vaadin.flow.component.AbstractSinglePropertyField<R,T>
-
- com.vaadin.flow.component.textfield.GeneratedVaadinTextField<R,T>
-
- com.vaadin.flow.component.textfield.GeneratedVaadinNumberField<C,T>
-
- com.vaadin.flow.component.textfield.AbstractNumberField<NumberField,Double>
-
- com.vaadin.flow.component.textfield.NumberField
-
All Implemented Interfaces:
AttachNotifier
,BlurNotifier<NumberField>
,CompositionNotifier
,DetachNotifier
,Focusable<NumberField>
,FocusNotifier<NumberField>
,HasElement
,HasEnabled
,HasHelper
,HasLabel
,HasSize
,HasStyle
,HasTheme
,HasValidation
,HasValue<AbstractField.ComponentValueChangeEvent<NumberField,Double>,Double>
,HasValueAndElement<AbstractField.ComponentValueChangeEvent<NumberField,Double>,Double>
,InputNotifier
,KeyNotifier
,HasClearButton
,HasAutocapitalize
,HasAutocomplete
,HasAutocorrect
,HasPrefixAndSuffix
,HasValueChangeMode
,Serializable
public class NumberField extends AbstractNumberField<NumberField,Double>
Number Field sports many of the same features as Text Field but only accepts numeric input. The input can be decimal, integral or big decimal. You can specify a unit as a prefix or suffix for the field.
Author:
Vaadin Ltd.
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.flow.component.textfield.GeneratedVaadinTextField
GeneratedVaadinTextField.ChangeEvent<R extends GeneratedVaadinTextField<R,?>>, GeneratedVaadinTextField.InvalidChangeEvent<R extends GeneratedVaadinTextField<R,?>>
-
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
AbstractField.ComponentValueChangeEvent<C extends Component,V>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
BlurNotifier.BlurEvent<C extends Component>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
FocusNotifier.FocusEvent<C extends Component>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
-
-
Field Summary
-
Fields inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
AUTOCAPITALIZE_ATTRIBUTE
-
Fields inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
AUTOCOMPLETE_ATTRIBUTE
-
Fields inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
AUTOCORRECT_ATTRIBUTE
-
Fields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUT
-
-
Constructor Summary
Constructors Constructor Description NumberField()
Constructs an empty
NumberField
.NumberField(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField,Double>> listener)
Constructs an empty
NumberField
with a value change listener.NumberField(String label)
Constructs an empty
NumberField
with the given label.NumberField(String label, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField,Double>> listener)
Constructs an empty
NumberField
with a value change listener and a label.NumberField(String label, Double initialValue, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField,Double>> listener)
Constructs a
NumberField
with a value change listener, a label and an initial value.NumberField(String label, String placeholder)
Constructs an empty
NumberField
with the given label and placeholder text.
-
Method Summary
All Methods Modifier and Type Method Description double
getMax()
The maximum value of the field.
int
getMaxLength()
Deprecated.
Not supported by NumberField (as it's built on<input type="number">
in HTML).double
getMin()
The minimum value of the field.
int
getMinLength()
Deprecated.
Not supported by NumberField (as it's built on<input type="number">
in HTML).String
getPattern()
Deprecated.
Not supported by NumberField (as it's built on<input type="number">
in HTML).double
getStep()
Specifies the allowed number intervals of the field.
boolean
isPreventInvalidInput()
Deprecated.
Not supported by NumberField (as it's built on<input type="number">
in HTML).void
setMax(double max)
Description copied from corresponding location in WebComponent:
void
setMaxLength(int maxLength)
Deprecated.
Not supported by NumberField (as it's built on<input type="number">
in HTML).void
setMin(double min)
Description copied from corresponding location in WebComponent:
void
setMinLength(int minLength)
Deprecated.
Not supported by NumberField (as it's built on<input type="number">
in HTML).void
setPattern(String pattern)
Deprecated.
Not supported by NumberField (as it's built on<input type="number">
in HTML).void
setPreventInvalidInput(boolean preventInvalidInput)
Deprecated.
Not supported by NumberField (as it's built on<input type="number">
in HTML).void
setStep(double step)
Sets the allowed number intervals of the field.
-
Methods inherited from class com.vaadin.flow.component.textfield.AbstractNumberField
getEmptyValue, getErrorMessage, getLabel, getMaxDouble, getMinDouble, getPlaceholder, getStepDouble, getTitle, getValue, getValueChangeMode, getValueChangeTimeout, hasControls, isAutofocus, isAutoselect, isInvalid, onAttach, setAutofocus, setAutoselect, setErrorMessage, setHasControls, setInvalid, setLabel, setPlaceholder, setRequiredIndicatorVisible, setTitle, setValue, setValueChangeMode, setValueChangeTimeout, validate
-
Methods inherited from class com.vaadin.flow.component.textfield.GeneratedVaadinNumberField
checkValidity, hasControlsBoolean
-
Methods inherited from class com.vaadin.flow.component.textfield.GeneratedVaadinTextField
addChangeListener, addInvalidChangeListener, addThemeVariants, addToInput, addToPrefix, addToSuffix, getAutocapitalizeString, getAutocompleteString, getAutocorrectString, getErrorMessageString, getLabelString, getListString, getMaxlengthDouble, getMinlengthDouble, getNameString, getPatternString, getPlaceholderString, getTitleString, isAutofocusBoolean, isAutoselectBoolean, isDisabledBoolean, isInvalidBoolean, isPreventInvalidInputBoolean, isReadonlyBoolean, isRequiredBoolean, remove, removeAll, removeThemeVariants, setAutocapitalize, setAutocomplete, setAutocorrect, setDisabled, setList, setMaxlength, setMinlength, setName, setReadonly, setRequired
-
Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
-
Methods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, isEmpty, setModelValue, valueEquals
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, scrollIntoView, set, setElement, setId, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
-
Methods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListener
-
Methods inherited from interface com.vaadin.flow.component.CompositionNotifier
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListener
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
Methods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
-
Methods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListener
-
Methods inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
getAutocapitalize, setAutocapitalize
-
Methods inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
getAutocomplete, setAutocomplete
-
Methods inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
isAutocorrect, setAutocorrect
-
Methods inherited from interface com.vaadin.flow.component.shared.HasClearButton
isClearButtonVisible, setClearButtonVisible
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
Methods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperText
-
Methods inherited from interface com.vaadin.flow.component.textfield.HasPrefixAndSuffix
getPrefixComponent, getSuffixComponent, setPrefixComponent, setSuffixComponent
-
Methods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
-
Methods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValue
-
Methods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly
-
Methods inherited from interface com.vaadin.flow.component.InputNotifier
addInputListener
-
Methods inherited from interface com.vaadin.flow.component.KeyNotifier
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
-
-
-
-
Constructor Detail
-
NumberField
public NumberField()
Constructs an empty
NumberField
.
-
NumberField
public NumberField(String label)
Constructs an empty
NumberField
with the given label.Parameters:
label
- the text to set as the label
-
NumberField
public NumberField(String label, String placeholder)
Constructs an empty
NumberField
with the given label and placeholder text.Parameters:
label
- the text to set as the labelplaceholder
- the placeholder text to set
-
NumberField
public NumberField(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField,Double>> listener)
Constructs an empty
NumberField
with a value change listener.Parameters:
listener
- the value change listenerSee Also:
AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
-
NumberField
public NumberField(String label, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField,Double>> listener)
Constructs an empty
NumberField
with a value change listener and a label.Parameters:
label
- the text to set as the labellistener
- the value change listenerSee Also:
AbstractNumberField.setLabel(String)
,AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
-
NumberField
public NumberField(String label, Double initialValue, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField,Double>> listener)
Constructs a
NumberField
with a value change listener, a label and an initial value.Parameters:
label
- the text to set as the labelinitialValue
- the initial valuelistener
- the value change listenerSee Also:
AbstractNumberField.setLabel(String)
,AbstractField.setValue(Object)
,AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
-
-
Method Detail
-
setMin
public void setMin(double min)
Description copied from class:
GeneratedVaadinNumberField
Description copied from corresponding location in WebComponent:
The minimum value of the field.
Overrides:
setMin
in classAbstractNumberField<NumberField,Double>
Parameters:
min
- the double value to set
-
getMin
public double getMin()
The minimum value of the field.
Returns:
the
min
property from the webcomponent
-
setMax
public void setMax(double max)
Description copied from class:
GeneratedVaadinNumberField
Description copied from corresponding location in WebComponent:
The maximum value of the field.
Overrides:
setMax
in classAbstractNumberField<NumberField,Double>
Parameters:
max
- the double value to set
-
getMax
public double getMax()
The maximum value of the field.
Returns:
the
max
property from the webcomponent
-
setStep
public void setStep(double step)
Sets the allowed number intervals of the field. This specifies how much the value will be increased/decreased. It is also used to invalidate the field, if the value doesn't align with the specified step and
min
(if specified by user).Overrides:
setStep
in classAbstractNumberField<NumberField,Double>
Parameters:
step
- the new step to setThrows:
IllegalArgumentException
- if the argument is less or equal to zero.
-
getStep
public double getStep()
Specifies the allowed number intervals of the field.
Returns:
the
step
property from the webcomponent
-
setMaxLength
@Deprecated public void setMaxLength(int maxLength)
Deprecated.Not supported by NumberField (as it's built on<input type="number">
in HTML). You can set numeric value constraints withsetMin(double)
,setMax(double)
andsetStep(double)
.Maximum number of characters (in Unicode code points) that the user can enter.
Parameters:
maxLength
- the maximum length
-
getMaxLength
@Deprecated public int getMaxLength()
Deprecated.Not supported by NumberField (as it's built on<input type="number">
in HTML). You can set numeric value constraints withsetMin(double)
,setMax(double)
andsetStep(double)
.Maximum number of characters (in Unicode code points) that the user can enter.
Returns:
the
maxlength
property from the webcomponent
-
setMinLength
@Deprecated public void setMinLength(int minLength)
Deprecated.Not supported by NumberField (as it's built on<input type="number">
in HTML). You can set numeric value constraints withsetMin(double)
,setMax(double)
andsetStep(double)
.Minimum number of characters (in Unicode code points) that the user can enter.
Parameters:
minLength
- the minimum length
-
getMinLength
@Deprecated public int getMinLength()
Deprecated.Not supported by NumberField (as it's built on<input type="number">
in HTML). You can set numeric value constraints withsetMin(double)
,setMax(double)
andsetStep(double)
.Minimum number of characters (in Unicode code points) that the user can enter.
Returns:
the
minlength
property from the webcomponent
-
isPreventInvalidInput
@Deprecated public boolean isPreventInvalidInput()
Deprecated.Not supported by NumberField (as it's built on<input type="number">
in HTML). You can set numeric value constraints withsetMin(double)
,setMax(double)
andsetStep(double)
. For setting a custom value pattern and preventing invalid input, use the TextField component instead.When set to
true
, user is prevented from typing a value that conflicts with the givenpattern
.Returns:
the
preventInvalidInput
property from the webcomponent
-
setPreventInvalidInput
@Deprecated public void setPreventInvalidInput(boolean preventInvalidInput)
Deprecated.Not supported by NumberField (as it's built on<input type="number">
in HTML). You can set numeric value constraints withsetMin(double)
,setMax(double)
andsetStep(double)
. For setting a custom value pattern and preventing invalid input, use the TextField component instead.Description copied from class:
GeneratedVaadinTextField
Description copied from corresponding location in WebComponent:
When set to true, user is prevented from typing a value that conflicts with the given
pattern
,maxlength
orminlength
properties.Overrides:
setPreventInvalidInput
in classGeneratedVaadinTextField<NumberField,Double>
Parameters:
preventInvalidInput
- the boolean value to set
-
setPattern
@Deprecated public void setPattern(String pattern)
Deprecated.Not supported by NumberField (as it's built on<input type="number">
in HTML). You can set numeric value constraints withsetMin(double)
,setMax(double)
andsetStep(double)
. For setting a custom value pattern, use the TextField component instead.Description copied from class:
GeneratedVaadinTextField
Description copied from corresponding location in WebComponent:
A regular expression that the value is checked against. The pattern must match the entire value, not just some subset.
Overrides:
setPattern
in classGeneratedVaadinTextField<NumberField,Double>
Parameters:
pattern
- the String value to set
-
getPattern
@Deprecated public String getPattern()
Deprecated.Not supported by NumberField (as it's built on<input type="number">
in HTML). You can set numeric value constraints withsetMin(double)
,setMax(double)
andsetStep(double)
. For setting a custom value pattern, use the TextField component instead.A regular expression that the value is checked against. The pattern must match the entire value, not just some subset.
Returns:
the
pattern
property from the webcomponent
-
-