Class SLabel

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
com.vaadin.flow.component.HtmlContainer
com.vaadin.flow.component.html.Span
com.vaadin.swingbridge.surrogates.SLabel
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.html.Span>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasComponentsOfType<com.vaadin.flow.component.Component>, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasText, ComponentMixin, Serializable

public class SLabel extends com.vaadin.flow.component.html.Span implements ComponentMixin
Surrogate for Label — AWT 1.0 static text, not JLabel. The whole JDK class is text plus a three-value alignment; no listeners, no icon, no mnemonic, no labelFor.
SLabel l = new SLabel("Total", SLabel.RIGHT);
l.setText("Total: 42");
l.setAlignment(SLabel.CENTER);   // → CSS text-align, read back losslessly

Hosts on Span — SJLabel's <label> exists for its labelFor wiring, which this class has none of. Rationale for that, for standing apart from SJLabel, and for mapping alignment onto text-align rather than SJLabel's flex shape: SD_sbutton's sibling entry SD_slabel.

Nothing is stored: text lives in the element's text content, so setText(null) reads back "" (R_vaadin_first loss — the emulator vaadinx.awt.Label shadows the field so its getter returns null verbatim per R_swing_is_truth); alignment lives in the CSS. No setter fires a PropertyChangeEvent, since AWT's don't — SJLabel does only because JLabel does.

See Also:
  • Field Details

    • LEFT

      public static final int LEFT
      java.awt.Label.LEFT — 0, which is not SwingConstants.LEFT.
      See Also:
    • CENTER

      public static final int CENTER
      java.awt.Label.CENTER — 1, which is not SwingConstants.CENTER.
      See Also:
  • Constructor Details

  • Method Details

    • setText

      public void setText(String text)
      Specified by:
      setText in interface com.vaadin.flow.component.HasText
      Parameters:
      text - null renders blank — Vaadin's element text content cannot hold null
    • getAlignment

      public int getAlignment()
      Returns:
      LEFT / CENTER / RIGHT; never lossy — the CSS keywords are in bijection with them
    • setAlignment

      public void setAlignment(int alignment)
      Throws:
      IllegalArgumentException - on a value outside LEFT / CENTER / RIGHT, before anything is written, so the label is left untouched (R_match_swing_errors)
    • paramString

      protected String paramString()
      AWT's Label.paramString tail: the alignment keyword and the text.
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()