Class NumberField
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<C,T>
com.vaadin.flow.component.AbstractSinglePropertyField<TComponent,TValue>
com.vaadin.flow.component.textfield.TextFieldBase<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,HasAllowedCharPattern,HasClearButton,HasClientValidation,HasPrefix,HasSuffix,HasThemeVariant<TextFieldVariant>,HasTooltip,HasValidationProperties,HasAutocapitalize,HasAutocomplete,HasAutocorrect,HasPrefixAndSuffix,HasValidator<Double>,HasValueChangeMode,Serializable
@Tag("vaadin-number-field")
@NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.0.2") @NpmPackage(value="@vaadin/number-field",version="24.0.2")
@JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/number-field/src/vaadin-number-field.js")
public class NumberField
extends AbstractNumberField<NumberField,Double>
implements HasAllowedCharPattern, HasThemeVariant<TextFieldVariant>
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.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.shared.HasClientValidation
HasClientValidation.ClientValidatedEventNested 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_ATTRIBUTEFields inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
AUTOCOMPLETE_ATTRIBUTEFields inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
AUTOCORRECT_ATTRIBUTEFields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptyNumberField.NumberField(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField, Double>> listener) Constructs an emptyNumberFieldwith a value change listener.NumberField(String label) Constructs an emptyNumberFieldwith the given label.NumberField(String label, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField, Double>> listener) Constructs an emptyNumberFieldwith a value change listener and a label.NumberField(String label, Double initialValue, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField, Double>> listener) Constructs aNumberFieldwith a value change listener, a label and an initial value.NumberField(String label, String placeholder) Constructs an emptyNumberFieldwith the given label and placeholder text. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetMax()The maximum value of the field.doublegetMin()The minimum value of the field.doublegetStep()Specifies the allowed number intervals of the field.voidsetMax(double max) Sets the maximum value of the field.voidsetMin(double min) Sets the minimum value of the field.voidsetStep(double step) Sets the allowed number intervals of the field.Methods inherited from class com.vaadin.flow.component.textfield.AbstractNumberField
addValidationStatusChangeListener, getDefaultValidator, getEmptyValue, getMaxDouble, getMinDouble, getStepDouble, getValue, isStepButtonsVisible, onAttach, setRequiredIndicatorVisible, setStepButtonsVisible, setValue, validateMethods inherited from class com.vaadin.flow.component.textfield.TextFieldBase
addToInput, addToPrefix, addToSuffix, getPlaceholder, getTitle, getValueChangeMode, getValueChangeTimeout, isAutofocus, isAutoselect, isRequired, setAutofocus, setAutoselect, setPlaceholder, setRequired, setTitle, setValueChangeMode, setValueChangeTimeoutMethods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, isEmpty, setModelValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.CompositionNotifier
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.shared.HasAllowedCharPattern
getAllowedCharPattern, setAllowedCharPatternMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
getAutocapitalize, setAutocapitalizeMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
getAutocomplete, setAutocompleteMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
isAutocorrect, setAutocorrectMethods inherited from interface com.vaadin.flow.component.shared.HasClearButton
isClearButtonVisible, setClearButtonVisibleMethods inherited from interface com.vaadin.flow.component.shared.HasClientValidation
addClientValidatedEventListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponentMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasSuffix
getSuffixComponent, setSuffixComponentMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariantsMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnlyMethods inherited from interface com.vaadin.flow.component.InputNotifier
addInputListenerMethods inherited from interface com.vaadin.flow.component.KeyNotifier
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
-
Constructor Details
-
NumberField
public NumberField()Constructs an emptyNumberField. -
NumberField
Constructs an emptyNumberFieldwith the given label.- Parameters:
label- the text to set as the label
-
NumberField
Constructs an emptyNumberFieldwith 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 emptyNumberFieldwith a value change listener.- Parameters:
listener- the value change listener- See Also:
-
NumberField
public NumberField(String label, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField, Double>> listener) Constructs an emptyNumberFieldwith a value change listener and a label.- Parameters:
label- the text to set as the labellistener- the value change listener- See Also:
-
NumberField
public NumberField(String label, Double initialValue, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<NumberField, Double>> listener) Constructs aNumberFieldwith 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 listener- See Also:
-
-
Method Details
-
setMin
public void setMin(double min) Description copied from class:AbstractNumberFieldSets the minimum value of the field.- Overrides:
setMinin classAbstractNumberField<NumberField,Double> - Parameters:
min- the double value to set
-
getMin
public double getMin()The minimum value of the field.- Returns:
- the
minproperty from the webcomponent
-
setMax
public void setMax(double max) Description copied from class:AbstractNumberFieldSets the maximum value of the field.- Overrides:
setMaxin classAbstractNumberField<NumberField,Double> - Parameters:
max- the double value to set
-
getMax
public double getMax()The maximum value of the field.- Returns:
- the
maxproperty 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 andmin(if specified by user).- Overrides:
setStepin classAbstractNumberField<NumberField,Double> - Parameters:
step- the new step to set- Throws:
IllegalArgumentException- if the argument is less or equal to zero.
-
getStep
public double getStep()Specifies the allowed number intervals of the field.- Returns:
- the
stepproperty from the webcomponent
-