Class SJFormattedTextField

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.textfield.TextField, String>
com.vaadin.flow.component.AbstractSinglePropertyField<com.vaadin.flow.component.textfield.TextField, String>
com.vaadin.flow.component.textfield.TextFieldBase<com.vaadin.flow.component.textfield.TextField, String>
com.vaadin.flow.component.textfield.TextField
com.vaadin.swingbridge.surrogates.SJTextField
com.vaadin.swingbridge.surrogates.SJFormattedTextField
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.textfield.TextField>, com.vaadin.flow.component.CompositionNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.component.textfield.TextField>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.textfield.TextField>, 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.textfield.TextField, String>, String>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.textfield.TextField, String>, String>, com.vaadin.flow.component.InputNotifier, com.vaadin.flow.component.KeyNotifier, com.vaadin.flow.component.shared.HasAllowedCharPattern, com.vaadin.flow.component.shared.HasClearButton, com.vaadin.flow.component.shared.HasPrefix, com.vaadin.flow.component.shared.HasSuffix, com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.textfield.TextFieldVariant>, 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.textfield.TextField, String>, String>, com.vaadin.flow.component.textfield.HasAutocapitalize, com.vaadin.flow.component.textfield.HasAutocomplete, com.vaadin.flow.component.textfield.HasAutocorrect, com.vaadin.flow.data.binder.HasValidator<String>, com.vaadin.flow.data.value.HasValueChangeMode, ComponentMixin, ContainerMixin, EnterClaims.Claimant, JComponentMixin, JTextComponentMixin, Serializable

public class SJFormattedTextField extends SJTextField
Surrogate for JFormattedTextField when the emulator's formatter dispatch lands on SJFormattedTextField's peer family per [SD_sjformatted_family](../../../../../decisions.md#SD_sjformatted_family) — the catch-all strategy (DefaultFormatter / no formatter / cross-family fallback) and the MaskFormatter strategy (browser-side pattern attribute).

Extends SJTextField (NOT just TextField) so the JTextField-shape surface — columns, horizontalAlignment, actionCommand, ActionListener-on-Enter via SJTextField's key wiring, JTextComponentMixin Document↔peer-text sync, setAction propagation — is inherited rather than duplicated. Per [SD_formatted_no_base_class](../../../../../decisions.md#SD_formatted_no_base_class) the JTextField surface is "duplicated per surrogate" only because Vaadin's parallel-not-shared peer hierarchy forces it for non-TextField peers (DatePicker / NumberField / IntegerField / LongField). When the peer IS-A TextField (this case), straight inheritance from SJTextField is the cleaner shape — no duplication, no copy-paste, the SJTextField surface is available to migrators directly.

JFormattedTextField-specific surface today:

focusLostBehavior + the COMMIT/etc constants stay inline rather than in a shared mixin: the surface (1 field + 4 constants) is too small across the formatted-field family to warrant the abstraction (R_infra_not_surface).

See Also:
  • Field Details

  • Constructor Details

    • SJFormattedTextField

      public SJFormattedTextField()
    • SJFormattedTextField

      public SJFormattedTextField(String text)
  • Method Details

    • claimsEnter

      public boolean claimsEnter()
      Enter commits an edit and only an unedited field lets it through — Swing's CommitAction, enabled by isEdited() rather than by listeners.
      Specified by:
      claimsEnter in interface EnterClaims.Claimant
      Overrides:
      claimsEnter in class SJTextField
    • setBrowserPattern

      public void setBrowserPattern(String regex)
      Set or clear the HTML pattern attribute for browser-side regex validation. Used by emulator-side MaskStrategy (D_formatted_strategy_interface) to push the converted MaskFormatter mask through to the input element. null clears the attribute.

      Cross-package access from vaadinx.swing.MaskStrategy requires public visibility. Pure-surrogate users should compose with Vaadin's standard validation API instead — this method exists for the emulator-side bridge per [SD_maskformatter_regex](../../../../../decisions.md#SD_maskformatter_regex).

    • getBrowserPattern

      public String getBrowserPattern()
      Read-back of the browser pattern; for diagnostics + tests.
    • getFocusLostBehavior

      public int getFocusLostBehavior()
    • setFocusLostBehavior

      public void setFocusLostBehavior(int behavior)
    • getUIClassID

      public String getUIClassID()
      Override the L&F class id to match JDK JFormattedTextField (which returns "FormattedTextFieldUI", distinct from JTextField's "TextFieldUI"). Pure cosmetic for L&F-aware UIManager lookups; we don't dispatch on the class id.
      Specified by:
      getUIClassID in interface JComponentMixin
      Overrides:
      getUIClassID in class SJTextField