Interface AbstractButtonMixin

All Superinterfaces:
ComponentMixin, ContainerMixin, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, ItemSelectable, JComponentMixin, Serializable
All Known Implementing Classes:
SJButton, SJCheckBox, SJRadioButton, SJToggleButton

public interface AbstractButtonMixin extends JComponentMixin, ItemSelectable
Mixin for AbstractButton. Layers the AbstractButton API surface on top of JComponentMixin. Shared across future SJButton / SJToggleButton / SJCheckBox / SJRadioButton surrogates — the push-vs-toggle split lives in the concrete's peer-click wiring (push buttons pulse setPressed, toggle buttons flip setSelected).

R_vaadin_first stance: UI functionality yes, API round-trip only where Vaadin has it

Per [R_vaadin_first], surrogates reproduce the UI functionality of their Swing originals — click → ActionEvent, ButtonModel armed/pressed pulse, ChangeListener / ItemListener fan-out, Action dispatch, mnemonic accelerators — but the API is only implemented to the degree Vaadin has a semantic counterpart. AbstractButton's still-uncovered visual state (the six state-conditional icons, border-painted / content-area-filled / focus-painted / rollover-enabled, margin, displayedMnemonicIndex, multiClickThreshhold) has no Vaadin counterpart today, so their setters call SHelper.onUnimplemented(Object, String, Object...) + drop the value, and their getters return the JDK default. See "Drop-and-WARN section" below.

The four alignment / text-position setters and iconTextGap do have a Vaadin counterpart (host display: inline-flex + flex-direction / justify-content / align-items / gap) and bind directly: setters write CSS, getters lossy-parse CSS back. Same setBorder / getBorder shape per SD_border_css_lossy — LEFT and LEADING both round-trip as LEADING, RIGHT and TRAILING as TRAILING; vertical text-position non-CENTER masks horizontal text-position.

Kept (UI-functional or semantically load-bearing):

  • text — written to the peer's element text property; read back from the same. Minor loss per R_vaadin_first: setText(null) round-trips as "".
  • actionCommand — drives ActionEvent's payload delivered to user listeners (with the text fallback).
  • hideActionText — gates NAME propagation inside configurePropertiesFromAction(Action).
  • mnemonic — drives Vaadin Shortcuts install; stored because Shortcuts is write-only (no readback).
  • Action state — install + PCL propagation + click dispatch.
  • ButtonModel state — source of truth for armed/pressed/selected/enabled; drives three fire-families.
  • Listener lists — ActionListener / ChangeListener / ItemListener fan-out.

Peer click synthesis

Concrete push-button surrogates call installButtonBindings() from their constructor. It seeds the default model, registers the three model-listener fan-out wires, and — if the concrete's peer implements ClickNotifier — wires a click listener that synthesizes a setArmed(true) → setPressed(true) → setPressed(false) → setArmed(false) pulse through SHelper.callSwing(Runnable) (R_callswing_envelope). The model's internal fireActionPerformed fires only on the pressed→unpressed transition while armed, matching JDK's sequence.

Mnemonic

setMnemonic installs a Vaadin Shortcuts binding for Alt+<key> on the concrete's peer that invokes doClick(). Replacing / clearing the mnemonic tears down the previous registration first. The Vaadin-side install is UI-scoped by default; close to Swing's WHEN_IN_FOCUSED_WINDOW for mnemonics on a single-UI app.

getIcon() / getUI() dropped — Vaadin Button signature clash

The mixin doesn't declare JDK-shaped getIcon() or getUI() getters. Vaadin Button.getIcon() returns com.vaadin.flow.component.Component and Component.getUI() returns Optional<UI> — neither is covariantly related to JDK's javax.swing.Icon / javax.swing.plaf.ButtonUI, so a surrogate extends Button cannot coexist with JDK-shaped versions (JVM forbids two methods with the same erased signature and different return types). setIcon(javax.swing.Icon) survives as an overload against Vaadin's setIcon(Component) (parameter types differ) and binds Vaadin-first per SD_vaadin_first_binding: ImageIcon reaches the peer as a PNG-encoded Vaadin Image; other Icon impls still WARN-and-drop pending Path 2 / Path 3.
  • Method Details

    • installButtonBindings

      default void installButtonBindings()
      Seeds the default ButtonModel + three model→button listener fan-outs. If the peer is a ClickNotifier, wires a click listener that synthesizes Swing armed/pressed pulses on user clicks. Idempotent: a second call is a no-op once model is installed.
    • synthesizePeerClick

      default void synthesizePeerClick()
      Synthesize a JDK-shaped click pulse on the installed ButtonModel. Mirrors doClick()'s effect but reaches the model directly so peer-originated clicks (user tap) flow through identical state transitions as a programmatic doClick.
    • getModel

      default ButtonModel getModel()
    • setModel

      default void setModel(ButtonModel newModel)
      Install a new ButtonModel. Detaches the mixin's bridge listeners from the old model via the stored ButtonStateStore.modelInstall handle, attaches fresh lambdas to the new model and packs their teardown into a single Registration, fires the "model" PCE. A null model is legal per JDK; the detach still happens so the old model doesn't retain references to our wires.
    • isSelected

      default boolean isSelected()
    • setSelected

      default void setSelected(boolean selected)
      Delegates to ButtonModel.setSelected(boolean). The model fires an ItemEvent on actual transition, which routes through the mixin's model-listener fan-out to button-level ItemListeners.
    • getSelectedObjects

      default Object[] getSelectedObjects()
      Specified by:
      getSelectedObjects in interface ItemSelectable
    • doClick

      default void doClick()
      Shorthand for doClick(68) per JDK.
    • doClick

      default void doClick(int pressTime)
      Programmatic click. Pulses the model's armed/pressed transitions (same path as a peer click); pressTime is nominal — we don't animate. Ignores isEnabled per JDK contract.
    • getText

      String getText()
      Abstract — each concrete AbstractButton-lineage surrogate provides its own getText via the parent Vaadin component's HasText contract. SJButton's inherited Button.getText() (which reads textNode) satisfies this requirement automatically. Mixin-internal callers (e.g. getActionCommand()'s text fallback, setDisplayedMnemonicIndex(int)'s length validation) reach the concrete impl via virtual dispatch.

      Pulled out of the mixin's default-implementation surface so the mixin doesn't need a reentry-flag dance to call back into the parent's HasText methods — the rendered text path is owned by the concrete surrogate, end of story.

    • setText

      void setText(String text)
      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 getText().
    • getLabel

      default String getLabel()
      Deprecated AWT 1.0 alias for getText().
    • setLabel

      default void setLabel(String label)
      Deprecated AWT 1.0 alias for setText(String).
    • getActionCommand

      default String getActionCommand()
    • setActionCommand

      default void setActionCommand(String command)
      Fires no "actionCommand" property change — the JDK's AbstractButton.setActionCommand is one line, getModel().setActionCommand(actionCommand), and nothing on the path fires (SD_property_fanout_audit).
    • getHideActionText

      default boolean getHideActionText()
    • setHideActionText

      default void setHideActionText(boolean hideActionText)
    • setIcon

      default void setIcon(Icon icon)
      Plain icon — bound Vaadin-first per SD_vaadin_first_binding (icon-rendering Path 1).

      Overload-safe against Vaadin Button.setIcon(Component) (parameter types differ). The translation runs through Icons.toVaadinIconComponent(Object, Icon): ImageIcon encodes as PNG and lands as a <img> child of the peer; any other Icon impl WARNs and clears the slot (Path 2 / Path 3 deferred).

      Fires "icon" PCE with Vaadin Component-typed values per R_vaadin_first (lossy round-trip — the JDK Icon ref isn't stored, since Vaadin Button owns the slot). Call sites whose peer doesn't expose setIcon(Component) (anything that isn't a Vaadin Button) WARN-and-drop, same shape as the pre-Path-1 fallback.

    • getPressedIcon

      default Icon getPressedIcon()
    • setPressedIcon

      default void setPressedIcon(Icon icon)
    • getSelectedIcon

      default Icon getSelectedIcon()
    • setSelectedIcon

      default void setSelectedIcon(Icon icon)
    • getDisabledIcon

      default Icon getDisabledIcon()
    • setDisabledIcon

      default void setDisabledIcon(Icon icon)
    • getDisabledSelectedIcon

      default Icon getDisabledSelectedIcon()
    • setDisabledSelectedIcon

      default void setDisabledSelectedIcon(Icon icon)
    • getRolloverIcon

      default Icon getRolloverIcon()
    • setRolloverIcon

      default void setRolloverIcon(Icon icon)
    • getRolloverSelectedIcon

      default Icon getRolloverSelectedIcon()
    • setRolloverSelectedIcon

      default void setRolloverSelectedIcon(Icon icon)
    • isBorderPainted

      default boolean isBorderPainted()
      JDK default is true; no Vaadin counterpart.
    • setBorderPainted

      default void setBorderPainted(boolean v)
    • isContentAreaFilled

      default boolean isContentAreaFilled()
      JDK default is true; no Vaadin counterpart.
    • setContentAreaFilled

      default void setContentAreaFilled(boolean v)
    • isFocusPainted

      default boolean isFocusPainted()
      JDK default is true; no Vaadin counterpart.
    • setFocusPainted

      default void setFocusPainted(boolean v)
    • isRolloverEnabled

      default boolean isRolloverEnabled()
      JDK default is false; no Vaadin counterpart.
    • setRolloverEnabled

      default void setRolloverEnabled(boolean v)
    • getIconTextGap

      default int getIconTextGap()
      Reads CSS gap back as an int. Lossy CSS round-trip per R_vaadin_first — a gap CSS value with a non-px unit (we only ever write "Npx") would parse to the JDK default 4.
    • setIconTextGap

      default void setIconTextGap(int gap)
    • getMargin

      default Insets getMargin()
      JDK default is null; no Vaadin counterpart.
    • setMargin

      default void setMargin(Insets margin)
    • getMultiClickThreshhold

      default long getMultiClickThreshhold()
      JDK default is 0. Validates per R_match_swing_errors; values > 0 drop with WARN.
    • setMultiClickThreshhold

      default void setMultiClickThreshhold(long threshhold)
    • getHorizontalAlignment

      default int getHorizontalAlignment()
    • setHorizontalAlignment

      default void setHorizontalAlignment(int alignment)
    • getVerticalAlignment

      default int getVerticalAlignment()
    • setVerticalAlignment

      default void setVerticalAlignment(int alignment)
    • getHorizontalTextPosition

      default int getHorizontalTextPosition()
    • setHorizontalTextPosition

      default void setHorizontalTextPosition(int pos)
    • getVerticalTextPosition

      default int getVerticalTextPosition()
    • setVerticalTextPosition

      default void setVerticalTextPosition(int pos)
    • getDisplayedMnemonicIndex

      default int getDisplayedMnemonicIndex()
      JDK default is -1. Validates per R_match_swing_errors; non-(-1) values drop with WARN.
    • setDisplayedMnemonicIndex

      default void setDisplayedMnemonicIndex(int index)
    • getMnemonic

      default int getMnemonic()
    • setMnemonic

      default void setMnemonic(int mnemonic)
      Install Alt+<mnemonic> as a Vaadin Shortcuts listener on the peer that invokes doClick(). Replacing / clearing tears down the previous registration first. Zero means "no mnemonic" and leaves the peer without a shortcut.
    • setMnemonic

      default void setMnemonic(char mnemonic)
      JDK's char→int path: uppercase ASCII-lower then delegate to the int variant.
    • addActionListener

      default void addActionListener(ActionListener l)
    • removeActionListener

      default void removeActionListener(ActionListener l)
    • getActionListeners

      default ActionListener[] getActionListeners()
    • addChangeListener

      default void addChangeListener(ChangeListener l)
    • removeChangeListener

      default void removeChangeListener(ChangeListener l)
    • getChangeListeners

      default ChangeListener[] getChangeListeners()
    • addItemListener

      default void addItemListener(ItemListener l)
      Specified by:
      addItemListener in interface ItemSelectable
    • removeItemListener

      default void removeItemListener(ItemListener l)
      Specified by:
      removeItemListener in interface ItemSelectable
    • getItemListeners

      default ItemListener[] getItemListeners()
    • fireActionPerformed

      default void fireActionPerformed(ActionEvent event)
      Re-sources the ActionEvent to this and iterates the button-level ActionListener list. LIFO order matches JDK.
    • fireStateChanged

      default void fireStateChanged()
      Fan-out for model change events; lazy ChangeEvent matches JDK.
    • fireItemStateChanged

      default void fireItemStateChanged(ItemEvent event)
      Fan-out for item events. JDK does not re-source.
    • getAction

      default Action getAction()
    • setAction

      default void setAction(Action a)
      Install / replace / clear the backing Action. Equals-based dedupe matches JDK. Teardown detaches the old Action's PCL and removes it from the ActionListener list; install copies name / command / icon / mnemonic / tooltip / enabled via configurePropertiesFromAction(Action) and registers a fresh PCL so Action mutations propagate. Fires the "action" PCE.
    • createActionPropertyChangeListener

      default PropertyChangeListener createActionPropertyChangeListener(Action a)
      Default PCL: routes Action mutations to actionPropertyChanged(Action, String).
    • actionPropertyChanged

      default void actionPropertyChanged(Action a, String propertyName)
      Per-key Action-mutation router. JDK's exact shape.
    • configurePropertiesFromAction

      default void configurePropertiesFromAction(Action a)
      JDK-shaped Action-property copy.
    • getUIClassID

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

      default void updateUI()
      Description copied from interface: JComponentMixin
      Deliberate no-op — L&F dispatch isn't modelled.
      Specified by:
      updateUI in interface JComponentMixin