Class SJSpinner
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.customfield.CustomField<Object>>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField<Object>>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.customfield.CustomField<Object>>, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasLabel, 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<com.vaadin.flow.component.customfield.CustomField<Object>, Object>, Object>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Object>, Object>, Object>, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.component.shared.HasValidationProperties, com.vaadin.flow.component.shared.InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Object>, Object>, Object>, ComponentMixin, ContainerMixin, EnterClaims.Claimant, JComponentMixin, Serializable
JSpinner (SD_sjspinner). Extends Vaadin
CustomField and carries a swappable inner Vaadin field whose
concrete type is picked from the installed SpinnerModel's
value type: IntegerField for SpinnerNumberModel(Integer),
LongField for SpinnerNumberModel(Long),
NumberField for Double/Float/BigDecimal/BigInteger,
DatePicker for SpinnerDateModel, Select for
SpinnerListModel, and a read-only TextField fallback
for unknown SpinnerModel implementations (so a migrated app at
least boots instead of crashing at construction).
Why CustomField, not a single leaf primitive
JSpinner's API allows swapping the model to a different-typed one at runtime (spinner.setModel(new SpinnerDateModel())); no single
Vaadin leaf primitive can morph from a numeric input into a date
picker into a select. CustomField is the Vaadin-native vehicle
for composing a value-carrying field from swappable child components —
on setModel(SpinnerModel) we tear down the old inner, add the new one, and
rewire the listener chain.
Model flow
The installedSpinnerModel is the source of truth (R_swing_is_truth). Our
ChangeListener on the model fans out to user
ChangeListeners, pushes the model's value / bounds / step
through to the inner field, and calls CustomField.updateValue()
so HasValue observers see the change through Vaadin channels
too. Browser-originated edits land on our explicit
HasValue listener on the inner field (wrapped in
SHelper.callSwing(Runnable), R_callswing_envelope); we coerce the peer-typed value back to
the model's type and write it through the model, which fires
ChangeEvent and closes the loop. The standard preventPeerEvents
flag (R_swing_is_truth) guards against peer→model→peer re-entry.
Read-only propagation
setReadOnly(boolean) is the user-facing bit; the inner field's
read-only state is userReadOnly || fallbackForcesReadOnly. For
unknown-model-type fallback (see createInnerFieldFor(SpinnerModel)) the
TextField stays locked regardless, so a migrated app can't silently
accept unparseable typed input into a model we can't round-trip.
Editor surface
Deferred per [D_emulator_surrogate_split] —getEditor / setEditor /
createEditor all WARN and return null; commitEdit is a
no-op (the peer listener already mirrors edits into the model on
every value change). Migrated code that reaches through getEditor()
for JFormattedTextField features will see the WARN.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E>Nested classes/interfaces inherited from interface JComponentMixin
JComponentMixin.ActionStandin -
Field Summary
Fields inherited from interface JComponentMixin
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanThe editor's rule: Swing's spinner editor is aJFormattedTextField, so Enter commits an edit and only an unedited editor lets it through.voidprotected voidprotected Objectcom.vaadin.flow.component.ComponentgetModel()Deliberate no-op — L&F key.getValue()voidvoidsetDatePattern(String pattern) Apply a JDKSimpleDateFormat-shaped pattern (e.g.voidsetEditor(com.vaadin.flow.component.Component editor) voidsetModel(SpinnerModel newModel) protected voidsetPresentationValue(Object newPresentationValue) voidsetReadOnly(boolean readOnly) voidMethods inherited from class com.vaadin.flow.component.customfield.CustomField
add, addThemeVariants, getLabel, remove, removeThemeVariants, setLabel, updateValueMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, bindValue, getEmptyValue, isEmpty, setModelValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class 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 ComponentMixin
_installSwingClass, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, dispatchEvent, doLayout, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getComponentListeners, getCursor, getFocusListeners, getFont, getForeground, getGraphics, getHierarchyBoundsListeners, getHierarchyListeners, getKeyListeners, getLocation, getMaximumSize, getMinimumSize, getMouseListeners, getName, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolTipText, getX, getY, grabFocus, hasFocus, invalidate, isDisplayable, isFocusable, isFocusOwner, isShowing, paint, paintAll, print, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, revalidate, setBackground, setBounds, setBounds, setCursor, setFocusable, setFont, setForeground, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validateMethods inherited from interface ContainerMixin
addContainerListener, getContainerListeners, getLayout, paintComponents, printComponents, removeContainerListener, setLayoutMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
bindHelperText, getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, 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, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipMarkdown, setTooltipTextMethods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidationMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, bindValue, clear, getEmptyValue, getOptionalValue, isEmptyMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
bindReadOnly, bindRequiredIndicatorVisible, isReadOnly, isRequiredIndicatorVisible, setRequiredIndicatorVisibleMethods inherited from interface JComponentMixin
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, isDoubleBuffered, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, requestDefaultFocus, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, updateUI
-
Constructor Details
-
SJSpinner
public SJSpinner() -
SJSpinner
-
-
Method Details
-
setDatePattern
Apply a JDKSimpleDateFormat-shaped pattern (e.g."yyyy-MM-dd","MM/dd/yyyy") to the underlying VaadinDatePickerviaDatePicker.setI18n(DatePicker.DatePickerI18n). No-op when the inner field isn't a DatePicker (the model isn't date-typed).R_layouts_close_enough best-effort: Vaadin's
DatePickerI18n.setDateFormataccepts JDK-shaped patterns directly for the date componentsyyyy / MM / dd / d / M / yy; time components in the pattern (e.g."yyyy-MM-dd HH:mm") are dropped silently — Vaadin DatePicker is date-only by construction. Mirrors SD_maskformatter_regex's SJFormattedDatePicker stance.Pattern is also stored on the surrogate so a subsequent
setModel(SpinnerDateModel)swap re-applies it to the freshly- built DatePicker (seeensureInnerFieldMatches(SpinnerModel)). -
getDatePattern
-
generateModelValue
-
setPresentationValue
-
setReadOnly
public void setReadOnly(boolean readOnly) - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Object>, Object>, Object>- Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Object>, Object>, Object>
-
setValue
JSpinner-shape behaviour: route through the model so migrated code sees the same contract as JDK
JSpinner—IllegalArgumentExceptionon out-of-range,ClassCastExceptionon wrong type. We deliberately bypassCustomField's internalsetModelValuepath; the subsequent modelChangeEventfans out tofanOutModelChange()which callsCustomField.updateValue()and so keeps CustomField's internal bookkeeping in sync.- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Object>, Object>, Object>- Overrides:
setValuein classcom.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<Object>, Object>
-
getValue
- Specified by:
getValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<Object>, Object>, Object>- Overrides:
getValuein classcom.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<Object>, Object>
-
getModel
-
setModel
-
getNextValue
-
getPreviousValue
-
addChangeListener
-
removeChangeListener
-
getChangeListeners
-
fireStateChanged
protected void fireStateChanged() -
getEditor
public com.vaadin.flow.component.Component getEditor() -
setEditor
public void setEditor(com.vaadin.flow.component.Component editor) -
commitEdit
public void commitEdit() -
claimsEnter
public boolean claimsEnter()The editor's rule: Swing's spinner editor is aJFormattedTextField, so Enter commits an edit and only an unedited editor lets it through.- Specified by:
claimsEnterin interfaceEnterClaims.Claimant
-
getUIClassID
Description copied from interface:JComponentMixinDeliberate no-op — L&F key.- Specified by:
getUIClassIDin interfaceJComponentMixin
-