Class SJButton

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.button.Button
com.vaadin.swingbridge.surrogates.SJButton
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.button.Button>, com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.button.Button>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.component.button.Button>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.button.Button>, com.vaadin.flow.component.HasAriaLabel, 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, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.shared.HasPrefix, com.vaadin.flow.component.shared.HasSuffix, com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.button.ButtonVariant>, com.vaadin.flow.component.shared.HasTooltip, ComponentMixin, ContainerMixin, AbstractButtonMixin, JComponentMixin, ItemSelectable, Serializable

public class SJButton extends com.vaadin.flow.component.button.Button implements AbstractButtonMixin
Surrogate for JButton (SD_sjbutton). Extends Vaadin Button directly (is-a) so it reaches the migrator either through :emulators.JButton as peer, or as a richer-than-stock Vaadin component in its own right.

Mixin split with SJToggleButton / SJCheckBox

The AbstractButtonMixin lineage is shared with future SJToggleButton / SJCheckBox / SJRadioButton surrogates — any AbstractButton method lives there. SJButton only adds the JButton-specific slice: defaultCapable + "defaultCapable" PCE, the stub isDefaultButton (true only when the enclosing root pane picks this as its default — surrogate-side root-pane wiring covers that through SJRootPane's separate defaultButton state), and the JButton.paramString tail.

Peer click → Swing ActionEvent

AbstractButtonMixin.installButtonBindings() wires the peer's ClickNotifier to AbstractButtonMixin.synthesizePeerClick(), which drives the installed ButtonModel through its armed/pressed pulse. Default model (DefaultButtonModel) fires an ActionEvent on the pressed→unpressed transition while armed, which the mixin's model-listener fan-out re-sources to this and delivers to user ActionListeners. User code that calls AbstractButtonMixin.doClick() takes the same model path, so programmatic and user clicks deliver identical event shapes.

defaultCapable and root-pane default-button integration

defaultCapable is field-round-trip + PCE; the actual "become the root pane's default button" wiring sits on SJRootPane. Migrated code that reads isDefaultCapable back after setting it works without touching the root pane. isDefaultButton returns false here (the button doesn't know which root pane owns it from the server side); SJRootPane is the canonical query point for default-button identity.
See Also:
  • Constructor Details

    • SJButton

      public SJButton()
    • SJButton

      public SJButton(String text)
    • SJButton

      public SJButton(Icon icon)
    • SJButton

      public SJButton(Action action)
    • SJButton

      public SJButton(String text, Icon icon)
  • Method Details

    • setText

      public void setText(String text)
      Description copied from interface: AbstractButtonMixin
      Abstract — each concrete surrogate implements via super (its Vaadin parent's HasText.setText, e.g. Button.setText → textSupport) plus the "text" PCE fire. Pulled out of the mixin's default surface for the same reason as AbstractButtonMixin.getText().
      Specified by:
      setText in interface AbstractButtonMixin
      Specified by:
      setText in interface com.vaadin.flow.component.HasText
      Overrides:
      setText in class com.vaadin.flow.component.button.Button
    • setEnabled

      public void setEnabled(boolean enabled)
      Java "classes beat interfaces" rule shadows the mixin chain's setEnabled (which carries SD_auto_pce's auto-PCE) with Vaadin HasEnabled's default. Redirect explicitly so the auto-PCE still fires on direct sjButton.setEnabled(...) calls.
      Specified by:
      setEnabled in interface ComponentMixin
      Specified by:
      setEnabled in interface com.vaadin.flow.component.HasEnabled
      Specified by:
      setEnabled in interface JComponentMixin
      Overrides:
      setEnabled in class com.vaadin.flow.component.button.Button
    • isDefaultCapable

      public boolean isDefaultCapable()
    • setDefaultCapable

      public void setDefaultCapable(boolean defaultCapable)
      Swing fires "defaultCapable" PCE; equal-value writes dedupe.
    • isDefaultButton

      public boolean isDefaultButton()
      Whether this button is the root pane's current default button. Returns false — the surrogate-side source of truth for default- button identity lives on SJRootPane (see its getDefaultButton()), and a button doesn't know which root pane owns it from the server side. Migrated code branching on this just takes the non-default path.
    • getUIClassID

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

      protected String paramString()
      JDK JButton appends ",defaultCapable=<bool>" to the AbstractButton shape. We skip the AbstractButton.paramString chain entirely (Vaadin's Component.toString is the honest host-side equivalent) and just report the JButton-specific flag.
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()