Class SJTextArea

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.textfield.TextArea, String>
com.vaadin.flow.component.AbstractSinglePropertyField<com.vaadin.flow.component.textfield.TextArea, String>
com.vaadin.flow.component.textfield.TextFieldBase<com.vaadin.flow.component.textfield.TextArea, String>
com.vaadin.flow.component.textfield.TextArea
com.vaadin.swingbridge.surrogates.SJTextArea
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.textfield.TextArea>, com.vaadin.flow.component.CompositionNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.component.textfield.TextArea>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.textfield.TextArea>, 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.TextArea, String>, String>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.textfield.TextArea, 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.TextAreaVariant>, 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.TextArea, 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 SJTextArea extends com.vaadin.flow.component.textfield.TextArea implements JTextComponentMixin, EnterClaims.Claimant
Surrogate for JTextArea, a consumer of SD_sjtextfield's JTextComponentMixin. Extends Vaadin TextArea directly (is-a). Reaches the migrator either through :emulators.JTextArea as peer, or as a richer-than-stock Vaadin component in its own right.

Why TextArea as peer (not TextField)

Vaadin TextArea renders <vaadin-text-area> backed by an HTML <textarea>, giving multi-line editing with native browser wrapping — what JTextArea exists to provide. TextArea extends TextFieldBase (sibling to TextField / PasswordField), so the mixin's R_swing_is_truth sync activates uniformly.

Override surface against JTextComponentMixin

  • validate() — visibility-widening override required by ComponentMixin's public validate() contract. Vaadin TextArea declares inherited validate() as protected (input validation, not Swing's layout cycle). Same shape SJTextField / SJPasswordField take per SD_sjtextfield / SD_sjpasswordfield.

JTextArea-specific surface

  • rows / columns — ctor + setters store the sizing hint and write peer.setMinRows(N) + peer.setWidth of a CssConvert.columnsToCssWidth(int) character-column hint per R_layouts_close_enough close-enough; negative throws IAE per R_match_swing_errors. JDK fires no PCE for either; we match.
  • tabSize / lineWrap / wrapStyleWord — field-only round-trip with PCE per JDK, no Vaadin counterpart. Vaadin TextArea wraps by default (browser textarea behaviour); there is no toggle to disable wrap without custom CSS, so lineWrap=false is observably ignored — accepted divergence (R_best_effort_behaviour best-effort, same call the emulator made). Likewise tabSize renders at the browser default.
  • append(String) / insert(String, int) / replaceRange(String, int, int) — Document mutation helpers, all three a bounds check in front of one private spliceDocument call: an append is a splice of the empty span at the end, an insert a splice of the empty span at pos. Each goes through the mixin's Document, so the R_swing_is_truth sync mirrors changes into the peer transparently (the peer never sees a half-updated state). Bad bounds throw IAE per R_match_swing_errors / JDK, each with its own message; null str is a documented no-op for append/insert and means "delete only" for replaceRange.
  • getLineCount() / getLineOfOffset(int) / getLineStartOffset(int) / getLineEndOffset(int) — PlainDocument's default root element holds one child per line, which is exactly Swing's line model for a JTextArea. BadLocationException on out-of-range matches JDK.
  • getUIClassID() == "TextAreaUI".

What is NOT here (vs SJTextField / SJPasswordField)

  • No ActionListener wiring on Enter. JDK JTextArea's Enter inserts a newline — that's the whole point of a multi-line editor. The Enter-as-submit shape lives on JTextField only.
  • No setAction(Action). JDK JTextArea doesn't have it (inherited surface stops at JTextComponent, not JTextField).
  • No horizontalAlignment. Same — JTextArea doesn't expose it; multi-line text follows ComponentOrientation only.
See Also:
  • Constructor Details

    • SJTextArea

      public SJTextArea()
    • SJTextArea

      public SJTextArea(String text)
    • SJTextArea

      public SJTextArea(int rows, int columns)
    • SJTextArea

      public SJTextArea(String text, int rows, int columns)
    • SJTextArea

      public SJTextArea(Document doc)
    • SJTextArea

      public SJTextArea(Document doc, String text, int rows, int columns)
  • Method Details

    • validate

      public void validate()
      Visibility-widening override of TextArea.validate() to satisfy ComponentMixin's public validate() contract. Delegates to super so Vaadin's input-validation behaviour is preserved. Same SJTextField / SJPasswordField pattern per SD_sjtextfield / SD_sjpasswordfield (method-name clash between Swing's "validate the layout" and Vaadin's "validate the input value" — same name, different concerns).
      Specified by:
      validate in interface ComponentMixin
      Overrides:
      validate in class com.vaadin.flow.component.textfield.TextArea
    • getRows

      public int getRows()
    • setRows

      public void setRows(int rows)
    • getColumns

      public int getColumns()
    • setColumns

      public void setColumns(int columns)
    • getTabSize

      public int getTabSize()
    • setTabSize

      public void setTabSize(int size)
    • getLineWrap

      public boolean getLineWrap()
    • setLineWrap

      public void setLineWrap(boolean wrap)
    • getWrapStyleWord

      public boolean getWrapStyleWord()
    • setWrapStyleWord

      public void setWrapStyleWord(boolean word)
    • append

      public void append(String str)
      Appends str to the Document, a splice of the empty span at the end. Null is a documented no-op per JDK.
    • insert

      public void insert(String str, int pos)
      Inserts str at offset pos, a splice of the empty span there. Null str is a documented no-op per JDK.
      Throws:
      IllegalArgumentException - if pos is outside the Document, per R_match_swing_errors — and checked here rather than in spliceDocument so the message stays the JDK's, which names the position rather than a range
    • replaceRange

      public void replaceRange(String str, int start, int end)
      Replaces the Document's [start, end) span with str.
      Parameters:
      str - the replacement, or null to delete the span and put nothing back — the JDK's "just delete" contract
      Throws:
      IllegalArgumentException - on a span the Document does not hold, per R_match_swing_errors
    • getLineCount

      public int getLineCount()
      Number of lines in the Document. PlainDocument's default root element has one child per line — that's exactly Swing's line count. Non-line-structured Documents return 0.
    • getLineOfOffset

      public int getLineOfOffset(int offset) throws BadLocationException
      Index of the line containing offset. JDK throws BadLocationException when offset is out of range; we match.
      Throws:
      BadLocationException
    • getLineStartOffset

      public int getLineStartOffset(int line) throws BadLocationException
      Start offset of line. JDK throws BadLocationException for out-of-range line; we match.
      Throws:
      BadLocationException
    • getLineEndOffset

      public int getLineEndOffset(int line) throws BadLocationException
      End offset of line. Includes the trailing newline (or EOF for the last line) per PlainDocument's element spec.
      Throws:
      BadLocationException
    • claimsEnter

      public boolean claimsEnter()
      Enter inserts a newline while editable — Swing's insert-break binding.
      Specified by:
      claimsEnter in interface EnterClaims.Claimant
    • getUIClassID

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

      protected String paramString()
      JDK JTextArea.paramString chains JTextComponent's tail and appends the JTextArea-specific state. We follow the same shape; underlying Vaadin Component.toString is the honest host-side equivalent.
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()