Class SJFormattedDatePicker

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.datepicker.DatePicker, LocalDate>
com.vaadin.flow.component.AbstractSinglePropertyField<com.vaadin.flow.component.datepicker.DatePicker, LocalDate>
com.vaadin.flow.component.datepicker.DatePicker
com.vaadin.swingbridge.surrogates.SJFormattedDatePicker
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.datepicker.DatePicker>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.component.datepicker.DatePicker>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.datepicker.DatePicker>, com.vaadin.flow.component.HasAriaDescription, 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<com.vaadin.flow.component.datepicker.DatePicker, LocalDate>, LocalDate>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.datepicker.DatePicker, LocalDate>, LocalDate>, com.vaadin.flow.component.shared.HasAllowedCharPattern, com.vaadin.flow.component.shared.HasAutoOpen, com.vaadin.flow.component.shared.HasClearButton, com.vaadin.flow.component.shared.HasPrefix, com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.datepicker.DatePickerVariant>, 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.datepicker.DatePicker, LocalDate>, LocalDate>, com.vaadin.flow.data.binder.HasValidator<LocalDate>, ComponentMixin, ContainerMixin, EnterClaims.Claimant, JComponentMixin, Serializable

public class SJFormattedDatePicker extends com.vaadin.flow.component.datepicker.DatePicker implements JComponentMixin, EnterClaims.Claimant
Surrogate for JFormattedTextField when the emulator's formatter selects SJFormattedDatePicker's peer family per [SD_sjformatted_family](../../../../../decisions.md#SD_sjformatted_family). Extends Vaadin DatePicker directly (is-a) so the rendered UI is the native Vaadin date picker — calendar popup + locale-driven typed-input parsing — rather than a plain text field with format validation.

R_swing_is_truth sync model — value source-of-truth is the peer

Per [SD_formatted_native_value](../../../../../decisions.md#SD_formatted_native_value) the surrogate's source of truth for the value is the peer's native getter (DatePicker.getValue() : LocalDate) — no shadow Object field. AbstractField.getValue() returns BrowserDateUtils.toDate(super.getValue()) (Date for JDK round-trip); DatePicker.setValue(Object) accepts a JDK Date (or LocalDate pass-through, or null), coerces, and writes through to the peer.

PropertyChangeEvent("value", oldDate, newDate) fires on every value change — both programmatic (setValue(Date)) and peer-originated (browser date pick). Wired via DatePicker's HasValue.ValueChangeEvent subscription, funneled through SHelper.callSwing(Runnable) per R_callswing_envelope. The PCE carries Date values on both ends; the LocalDate→Date conversion runs inside the Vaadin listener so PropertyChangeListeners see JDK types.

ActionListener fan-out on Enter + value commit

JDK JFormattedTextField inherits ActionListener-on-Enter from JTextField — for the SJFormattedDatePicker peer the natural "commit" signals are (a) Enter on the input subfield and (b) browser date pick (value-change). Both fire ActionEvent with source = this and actionCommand = "" (no defined action command for date input; pure-surrogate users can override with setActionCommand(String) if migrated logic needs one).

R_vaadin_first drop-and-WARN surface

  • setColumns(int) / getColumns() — DatePicker has its own width sizing; setColumns has no peer concept. Field-shadow round-trip with WARN on non-zero set per [SD_formatted_no_base_class](../../../../../decisions.md#SD_formatted_no_base_class) (JTextField surface duplicated, drop-and-WARN where Vaadin lacks the concept).
  • setHorizontalAlignment(int) — same as SJTextField's stance (Vaadin DatePicker shadow DOM doesn't expose host text-align). R_match_swing_errors IAE on bad axis preserved; non-LEADING values WARN.
  • L&F getUI / setUI — WARN-and-noop per the surrogate-wide stance (Vaadin owns the DOM).

focusLostBehavior + the COMMIT / REVERT constants live inline rather than in a shared SJFormattedFieldMixin: the surface is too small across the formatted-field family to warrant the abstraction (R_infra_not_surface, [SD_sjformattedfieldmixin](../../../../../decisions.md#SD_sjformattedfieldmixin)).

See Also:
  • Field Details

  • Constructor Details

    • SJFormattedDatePicker

      public SJFormattedDatePicker()
    • SJFormattedDatePicker

      public SJFormattedDatePicker(Date initialValue)
  • Method Details

    • validate

      public void validate()
      Visibility-widening override of DatePicker.validate() to satisfy ComponentMixin's public validate() contract. Vaadin DatePicker declares the inherited validate() as protected (input validation, not Swing's layout cycle). Same shape SJTextField takes per SD_sjtextfield.
      Specified by:
      validate in interface ComponentMixin
      Overrides:
      validate in class com.vaadin.flow.component.datepicker.DatePicker
    • getDateValue

      public Date getDateValue()
      R_vaadin_first + Vaadin generics: the inherited super.getValue() returns LocalDate; an Object getValue() override would erasure-clash with HasValue<C, V>.getValue(). Pure-surrogate users read super.getValue() directly; emulator code uses these convenience accessors plus BrowserDateUtils.toLocalDate(Date) / BrowserDateUtils.toDate(LocalDate) for Date↔LocalDate coercion at the boundary per [SD_formatted_native_value](../../../../../decisions.md#SD_formatted_native_value) (peer's native type is the source of truth).
    • setDateValue

      public void setDateValue(Date value)
      Date-typed setter that funnels through the peer's LocalDate setter with preventPeerEvents guard so the value-change bridge doesn't double-fire PropertyChangeEvent("value", ...). The PCE fires here once with both old and new as JDK Date so PropertyChangeListeners see consistent JDK types regardless of the write origin.
    • getFocusLostBehavior

      public int getFocusLostBehavior()
    • setFocusLostBehavior

      public void setFocusLostBehavior(int behavior)
      Round-trip storage for the JDK focusLostBehavior int. The actual focus-lost commit logic lives on the emulator-side strategy (D_jformattedtextfield) — the surrogate stores the int so getFocusLostBehavior round-trips and emulator code can read it back.
    • addActionListener

      public void addActionListener(ActionListener l)
    • removeActionListener

      public void removeActionListener(ActionListener l)
    • getActionListeners

      public ActionListener[] getActionListeners()
    • fireActionPerformed

      protected void fireActionPerformed()
      Fire ActionEvent with source = this. actionCommand defaults to "" (no natural text representation for a date — formatter-driven stringification lives emulator-side).
    • setActionCommand

      public void setActionCommand(String command)
    • getColumns

      public int getColumns()
    • setColumns

      public void setColumns(int columns)
      Field-shadow round-trip only — DatePicker has no columns concept. Per [SD_formatted_no_base_class](../../../../../decisions.md#SD_formatted_no_base_class), the JTextField surface is duplicated per surrogate and drops where Vaadin lacks the concept. Negative throws IAE per R_match_swing_errors.
    • getHorizontalAlignment

      public int getHorizontalAlignment()
    • setHorizontalAlignment

      public void setHorizontalAlignment(int alignment)
    • getUIClassID

      public String getUIClassID()
      Description copied from interface: JComponentMixin
      Deliberate no-op — L&F key.
      Specified by:
      getUIClassID in interface JComponentMixin
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()
    • claimsEnter

      public boolean claimsEnter()
      The SJFormattedTextField.claimsEnter() rule: Enter commits an edit and only an unedited field lets it through.
      Specified by:
      claimsEnter in interface EnterClaims.Claimant