Class NumberField

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<C,T>
com.vaadin.flow.component.AbstractSinglePropertyField<TComponent,TValue>
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<NumberField>, com.vaadin.flow.component.CompositionNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<NumberField>, com.vaadin.flow.component.FocusNotifier<NumberField>, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasPlaceholder, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<NumberField,Double>,Double>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<NumberField,Double>,Double>, com.vaadin.flow.component.InputNotifier, com.vaadin.flow.component.KeyNotifier, HasAllowedCharPattern, HasClearButton, HasClientValidation, HasPrefix, HasSuffix, HasThemeVariant<TextFieldVariant>, HasTooltip, HasValidationProperties, InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<NumberField,Double>,Double>, HasAutocapitalize, HasAutocomplete, HasAutocorrect, HasPrefixAndSuffix, com.vaadin.flow.data.binder.HasValidator<Double>, com.vaadin.flow.data.value.HasValueChangeMode, Serializable

@Tag("vaadin-number-field") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.4.5") @NpmPackage(value="@vaadin/number-field",version="24.4.5") @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

    com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V extends Object>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier

    com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier

    com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.shared.HasClientValidation

    HasClientValidation.ClientValidatedEvent

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue

    com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.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
    Constructs an empty NumberField.
    NumberField(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<NumberField,Double>> listener)
    Constructs an empty NumberField with a value change listener.
    Constructs an empty NumberField with the given label.
    NumberField(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<NumberField,Double>> listener)
    Constructs an empty NumberField with a value change listener and a label.
    NumberField(String label, Double initialValue, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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

    Modifier and Type
    Method
    Description
    double
    The maximum value of the field.
    double
    The minimum value of the field.
    double
    Specifies the allowed number intervals of the field.
    void
    setMax(double max)
    Sets the maximum value of the field.
    void
    setMin(double min)
    Sets the minimum value of the field.
    void
    setStep(double step)
    Sets the allowed number intervals of the field.

    Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField

    getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent

    Methods inherited from class com.vaadin.flow.component.AbstractField

    addValueChangeListener, isEmpty, valueEquals

    Methods 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, 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.shared.HasAllowedCharPattern

    getAllowedCharPattern, setAllowedCharPattern

    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.shared.HasClientValidation

    addClientValidatedEventListener

    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.HasLabel

    getLabel

    Methods inherited from interface com.vaadin.flow.component.HasPlaceholder

    getPlaceholder, setPlaceholder

    Methods inherited from interface com.vaadin.flow.component.shared.HasPrefix

    getPrefixComponent, setPrefixComponent

    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.shared.HasSuffix

    getSuffixComponent, setSuffixComponent

    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.shared.HasThemeVariant

    addThemeVariants, removeThemeVariants

    Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip

    getTooltip, setTooltipText

    Methods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties

    getErrorMessage, isInvalid, setErrorMessage, setInvalid

    Methods inherited from interface com.vaadin.flow.component.HasValue

    addValueChangeListener, clear, getOptionalValue, isEmpty

    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 Details

    • 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 label
      placeholder - the placeholder text to set
    • NumberField

      public NumberField(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<NumberField,Double>> listener)
      Constructs an empty NumberField with a value change listener.
      Parameters:
      listener - the value change listener
      See Also:
      • AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
    • NumberField

      public NumberField(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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 label
      listener - the value change listener
      See Also:
    • NumberField

      public NumberField(String label, Double initialValue, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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 label
      initialValue - the initial value
      listener - the value change listener
      See Also:
      • TextFieldBase.setLabel(String)
      • AbstractField.setValue(Object)
      • AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
  • Method Details

    • setMin

      public void setMin(double min)
      Description copied from class: AbstractNumberField
      Sets the minimum value of the field.
      Overrides:
      setMin in class AbstractNumberField<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: AbstractNumberField
      Sets the maximum value of the field.
      Overrides:
      setMax in class AbstractNumberField<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 class AbstractNumberField<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 step property from the webcomponent