Interface ComponentMixin

All Superinterfaces:
com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, Serializable
All Known Subinterfaces:
AbstractButtonMixin, ContainerMixin, JComponentMixin, JTextComponentMixin
All Known Implementing Classes:
SButton, SCheckbox, SChoice, SFrame, SJButton, SJCheckBox, SJColorChooser, SJComboBox, SJDialog, SJEditorPane, SJFormattedDatePicker, SJFormattedIntegerField, SJFormattedLongField, SJFormattedNumberField, SJFormattedTextField, SJFrame, SJInternalFrame, SJLabel, SJList, SJMenuBar, SJPanel, SJPasswordField, SJPopupMenu, SJProgressBar, SJRadioButton, SJRootPane, SJScrollPane, SJSeparator, SJSlider, SJSpinner, SJSplitPane, SJTabbedPane, SJTable, SJTextArea, SJTextField, SJToggleButton, SJToolBar, SJTree, SJWindow, SLabel, SList, SScrollbar, SScrollPane, SWindow

public interface ComponentMixin extends com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize
Mixin that adds the Component API surface to any Vaadin component subclass. See surrogates/architecture.md for the design.

Vaadin-first direct binding (SD_vaadin_first_binding): every Swing method routes straight to its Vaadin counterpart when one exists; where Vaadin has no direct analog we warn + noop rather than carrying a server-side shadow cache. Listener registrations wire Vaadin subscriptions eagerly via the unified Registrations registry, so addFocusListener actually fires on browser focus — no store-only intermediate state.

Extends HasEnabled and HasSize so setEnabled / isEnabled / getElement and Vaadin's CSS-string setWidth / getHeight family are available without conflict. setVisible / isVisible come from the surrogate's Vaadin parent. Surrogates of Vaadin classes that implement neither cannot implement this mixin.

Lossy round-trip is accepted (SD_vaadin_first_binding): setForeground / getForeground reconstruct the Color from CSS each time, which may lose one bit of alpha precision; setFont / getFont similarly collapse intermediate CSS weights to plain/bold and non-px sizes to 12. Appears identical to user code for the common cases.

Excluded entirely: getParent, add/remove(Component), getComponent(int), getComponents(), getComponentCount(), isAncestorOf(Component). Hard signature clash with Vaadin's hierarchy API; Vaadin's wins.

UI-thread-confined — the layer-wide default for every surrogate (a surrogate is-a Vaadin component, and Vaadin mutation is UI-thread-only). Migrated code reaching in from a background thread marshals via UI.access; peer→Swing event callbacks re-enter on the UI thread through SHelper.callSwing(Runnable) (R_callswing_envelope). Stated here once for the whole hierarchy: concrete surrogates note only where a method deviates (self-marshals or is safe off-thread), and none re-declare the baseline.

  • Method Details

    • getName

      default String getName()
      Reads the NameStore slot.
    • setName

      default void setName(String name)
      Writes to NameStore only — deliberately does not touch Vaadin's setId. Vaadin's id is a CSS-targetable element identifier; Swing's name is metadata that no Swing UI inspects.

      Mirrors the name onto the data-swing-name DOM attribute so the value is visible in DevTools without exposing it through id (which would force uniqueness Swing's name doesn't have). Cleared when name is null / blank.

      Fires "name" PCE per Swing's Component contract (SD_auto_pce).

    • _installSwingClass

      default void _installSwingClass()
      Stamp data-swing-class on this surrogate's element using its runtime class. Called once from each surrogate's constructor; an emulator wrapping this surrogate will overwrite with its own class (last-write-wins is the desired stage-2/stage-3 distinction).
    • setEnabled

      default void setEnabled(boolean enabled)
      Overrides HasEnabled.setEnabled(boolean) for the no-op-on-equal guard. Fires no "enabled" property change: java.awt.Component.setEnabled delegates to the deprecated enable(), which fires only AccessibleContext.ACCESSIBLE_STATE_PROPERTY on the accessible context's own listener list — nothing a component.addPropertyChangeListener ever sees. The bound "enabled" property is JComponentMixin's override, which is where the JDK puts it too (SD_property_fanout_audit), so AWT-level surrogates (SButton, SLabel, SChoice, SCheckbox, SList, SScrollbar, SScrollPane, SWindow) correctly stay silent.
      Specified by:
      setEnabled in interface com.vaadin.flow.component.HasEnabled
    • setToolTipText

      default void setToolTipText(String text)
      Delegates directly to Vaadin's HasTooltip.setTooltipText(String). Non-HasTooltip peers log via SHelper.onUnimplemented(Object, String, Object...) — the Vaadin-first stance skips a server-side shadow cache: if the peer can't render a tooltip, we don't pretend to carry the value.
    • getToolTipText

      default String getToolTipText()
      Reads from HasTooltip.getTooltip(); non-HasTooltip peers log and return null. No server-side store: the tooltip value is whatever the peer currently carries.
    • requestFocus

      default void requestFocus()
      Vaadin's analog is Focusable.focus(). instanceof-gated so non-Focusable surrogates log an onUnimplemented. The four variants collapse — we have no server-side distinction for AWT's temporary/permanent or in-window/global focus.
    • requestFocus

      default boolean requestFocus(boolean temporary)
      Returns true unconditionally — Vaadin's focus() is fire-and-forget. Matches the AWT default of "we tried, we don't know."
    • requestFocusInWindow

      default void requestFocusInWindow()
      Same path as requestFocus().
    • requestFocusInWindow

      default boolean requestFocusInWindow(boolean temporary)
    • grabFocus

      default void grabFocus()
      Swing's grabFocus is "request focus and force it"; Vaadin has no force option.
    • getForeground

      default Color getForeground()
      Reconstructs the foreground Color from CSS color; null if unset/unparseable.
    • setForeground

      default void setForeground(Color c)
      Writes CSS color. null removes the property for parent-inheritance — matches Swing's "null means inherit" contract.

      Fires "foreground" PCE per Swing's Component contract (SD_auto_pce). Old-value is read through getForeground() which reconstructs from CSS — one-bit alpha lossiness can cause a second identical set to fire a spurious PCE (reconstructed alpha ≠ original alpha). Same SD_border_css_lossy/SD_auto_pce round-trip caveat applies.

    • getBackground

      default Color getBackground()
      Reconstructs the background Color from CSS background-color.
    • setBackground

      default void setBackground(Color c)
      CSS background-color. null removes the property. Fires "background" PCE per Swing's Component contract (SD_auto_pce).
    • getFont

      default Font getFont()
      Reconstructs a Font from the four CSS slots (font-family / font-size / font-weight / font-style). Lossy — see class-level Javadoc. When no font CSS is set, returns CssConvert.DEFAULT_FONT rather than null: real Swing installs an L&F default font at construction, so getFont() is non-null, and the ubiquitous GUI-builder idiom getFont().deriveFont(...) relies on it. Callers that need the local-only "was a font explicitly set" answer read the font-* style slots directly rather than diffing against this default.
    • setFont

      default void setFont(Font f)
      Writes the full font quartet on every set so a previous setFont's leftover style fragments don't bleed through. null removes all four for parent-inheritance.

      Fires "font" PCE per Swing's Component contract (SD_auto_pce). Old-value comes from getFont() which reconstructs from CSS — weight/style quantisation (weights outside bold/normal collapse, etc.) can cause a second identical set to fire a spurious PCE. Same SD_auto_pce round-trip caveat as foreground/background.

    • addPropertyChangeListener

      default void addPropertyChangeListener(PropertyChangeListener listener)
      Backed by per-component PropertyChangeSupport via PceSupport.
    • addPropertyChangeListener

      default void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Name-filtered registration — PropertyChangeSupport handles the name dispatch internally.
    • removePropertyChangeListener

      default void removePropertyChangeListener(PropertyChangeListener listener)
      Removes a previously registered general listener.
    • removePropertyChangeListener

      default void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Removes listeners registered with the matching property name.
    • getPropertyChangeListeners

      default PropertyChangeListener[] getPropertyChangeListeners()
      Returns all listeners — general + name-filtered wrappers per JDK contract.
    • getPropertyChangeListeners

      default PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
      Returns only listeners registered for the given property name.
    • firePropertyChange

      default void firePropertyChange(String propertyName, Object oldValue, Object newValue)
      Fires to registered listeners. setName(String), setEnabled(boolean), setForeground(Color), setBackground(Color), setFont(Font) all auto-fire under this path (SD_auto_pce).
    • firePropertyChange

      default void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
      Boolean overload.
    • firePropertyChange

      default void firePropertyChange(String propertyName, int oldValue, int newValue)
      Int overload.
    • addComponentListener

      default void addComponentListener(SComponentListener listener)
      Registers the listener via Registrations and wires the peer's attach/detach events to dispatch SComponentEvent.COMPONENT_SHOWN and SComponentEvent.COMPONENT_HIDDEN. Resize and move aren't surfaced by Vaadin server-side in the general case; those callbacks never fire today (SD_vaadin_first_binding accepts partial coverage — browser is authoritative).
    • removeComponentListener

      default void removeComponentListener(SComponentListener listener)
      Symmetric — removes both peer subscriptions wired by addComponentListener(SComponentListener).
    • getComponentListeners

      default SComponentListener[] getComponentListeners()
      Returns the currently registered SComponentListeners in registration order.
    • setBounds

      default void setBounds(int x, int y, int width, int height)
      See class-level "Bucket A" — x/y can't be honoured under CSS flow; logs via SHelper.onNoop(Object, String).
    • setBounds

      default void setBounds(Rectangle r)
      Rectangle overload.
    • getBounds

      default Rectangle getBounds()
      (0, 0, width, height) — origin is always (0, 0) since we have no server-side pixel coordinate.
    • setSize

      default void setSize(int width, int height)
      Writes pixel dimensions via HasSize in "Npx" form.
    • setSize

      default void setSize(Dimension d)
      Dimension overload; null is onNoop.
    • getSize

      default Dimension getSize()
      Reads HasSize back; non-pixel values fall back to 1 (see CssConvert.parsePxOr1(String)).
    • setLocation

      default void setLocation(int x, int y)
      Bucket B SHelper.onNoop(Object, String) — no absolute-positioning layout exists at this layer (R_layouts_close_enough: pixel-accurate layout is out of scope permanently — D_pixel_layout_not_planned). This is onNoop rather than onUnimplemented: there is no upstream-blocked counterpart we are waiting on, so a WARN would be misleading.
    • setLocation

      default void setLocation(Point p)
      Point overload — see setLocation(int, int).
    • getLocation

      default Point getLocation()
      Origin — chained reads don't NPE.
    • getX

      default int getX()
      Bucket B — see setLocation(int, int).
    • getY

      default int getY()
      Bucket B — see setLocation(int, int).
    • setPreferredSize

      default void setPreferredSize(Dimension d)
      Routes to setSize(Dimension). Vaadin has only one dimension per axis; "preferred" and "actual" collapse onto the same CSS value.

      Fires "preferredSize" and only that name, even though the collapse means this call also changes what getMinimumSize() and getMaximumSize() answer. AWT fires one name per setter, and firing the other two would be inventing events real Swing does not send — the thing [SD_no_invented_events](../../../../../../surrogates/decisions.md) rules out. See sizeBefore() for how the old value reproduces AWT's null-for-unset without a shadow flag.

    • getPreferredSize

      default Dimension getPreferredSize()
      Reads the single HasSize dimension — same value getSize() returns.
    • setMinimumSize

      default void setMinimumSize(Dimension d)
    • getMinimumSize

      default Dimension getMinimumSize()
    • setMaximumSize

      default void setMaximumSize(Dimension d)
    • getMaximumSize

      default Dimension getMaximumSize()
    • repaint

      default void repaint()
      Deliberate no-op; the browser repaints when the DOM changes.
    • repaint

      default void repaint(long tm)
      Timed-repaint variant.
    • repaint

      default void repaint(int x, int y, int w, int h)
      Region repaint.
    • repaint

      default void repaint(long tm, int x, int y, int w, int h)
      Timed region repaint.
    • repaint

      default void repaint(Rectangle r)
      Rectangle region repaint.
    • revalidate

      default void revalidate()
      Deliberate no-op; Vaadin has no Swing-style validate cycle.
    • invalidate

      default void invalidate()
      Deliberate no-op.
    • validate

      default void validate()
      Deliberate no-op.
    • doLayout

      default void doLayout()
      Deliberate no-op; layout is browser-driven.
    • paint

      default void paint(Graphics g)
      Deliberate no-op; no Graphics to paint into.
    • update

      default void update(Graphics g)
      Deliberate no-op.
    • paintAll

      default void paintAll(Graphics g)
      Deliberate no-op.
    • print

      default void print(Graphics g)
      Deliberate no-op.
    • printAll

      default void printAll(Graphics g)
      Deliberate no-op.
    • getGraphics

      default Graphics getGraphics()
      Returns null — no offscreen Graphics exists for a Vaadin component.
    • addNotify

      default void addNotify()
      Deliberate no-op; AWT native-peer lifecycle has no Vaadin analog.
    • removeNotify

      default void removeNotify()
      Deliberate no-op.
    • addFocusListener

      default void addFocusListener(SFocusListener l)
      Registers with FocusNotifier/BlurNotifier when the peer supports them, dispatching SFocusEvent via the user's SFocusListener. Non-focusable peers log and skip wiring — there's nothing useful to listen to.
    • removeFocusListener

      default void removeFocusListener(SFocusListener l)
      Symmetric — removes the wired Vaadin subscriptions.
    • getFocusListeners

      default SFocusListener[] getFocusListeners()
      Returns currently registered focus listeners in registration order.
    • addKeyListener

      default void addKeyListener(SKeyListener l)
      Registers with KeyNotifier when the peer supports it, dispatching SKeyEvent via the user's SKeyListener. Non-KeyNotifier peers log and skip wiring — no browser-side keyboard event can reach them, so storing the listener would mislead.

      One user listener installs three Vaadin subscriptions and composes them into a single Registration: keydown → KEY_PRESSED, keypress → KEY_TYPED, keyup → KEY_RELEASED. Every dispatch wraps through SHelper.callSwing(Runnable) (R_callswing_envelope) so the blocking-dialog hook lands in one place. See SD_key_events for the mapping rationale.

    • removeKeyListener

      default void removeKeyListener(SKeyListener l)
      Symmetric — removes all three wired Vaadin subscriptions.
    • getKeyListeners

      default SKeyListener[] getKeyListeners()
      Returns currently registered key listeners in registration order.
    • addMouseListener

      default void addMouseListener(SMouseListener l)
      Registers with Vaadin ClickNotifier when the peer supports it, dispatching SMouseEvent.MOUSE_CLICKED via the user's SMouseListener.mouseClicked(SMouseEvent). Non-ClickNotifier peers log SHelper.onUnimplemented(Object, String, Object...) and skip wiring.

      Partial coverage. Only mouseClicked fires under this wire. The press / release / enter / exit overloads are part of the JDK contract — your listener implements them — but never reach the user. Vaadin doesn't surface those DOM mouse events server-side without a custom listener stack (out of scope here); same shape that addKeyListener(SKeyListener) takes by covering only the KeyNotifier subset of the JDK key surface. addMouseMotionListener and addMouseWheelListener stay drop-and-WARN with a documented gap below — neither has a Vaadin counterpart at all.

      Every dispatch wraps through SHelper.callSwing(Runnable) (R_callswing_envelope) so the blocking-dialog hook lands in one place. Modifier translation: Vaadin's four boolean modifier flags (ctrl/shift/alt/meta) project to the *_DOWN_MASK bits; button mapping is Vaadin-DOM (0/1/2 left/middle/right) → SMouseEvent.BUTTON1/BUTTON2/BUTTON3, with unknown (-1) reading as SMouseEvent.NOBUTTON.

    • removeMouseListener

      default void removeMouseListener(SMouseListener l)
      Symmetric — removes the wired Vaadin subscription.
    • getMouseListeners

      default SMouseListener[] getMouseListeners()
      Returns currently registered mouse listeners in registration order.
    • addMouseMotionListener

      default void addMouseMotionListener(MouseMotionListener l)
      WARN — Vaadin has no server-side mouse-motion event source.
    • removeMouseMotionListener

      default void removeMouseMotionListener(MouseMotionListener l)
    • addMouseWheelListener

      default void addMouseWheelListener(MouseWheelListener l)
      WARN — Vaadin has no server-side mouse-wheel event source.
    • removeMouseWheelListener

      default void removeMouseWheelListener(MouseWheelListener l)
    • addInputMethodListener

      default void addInputMethodListener(InputMethodListener l)
      WARN — input-method events have no web equivalent.
    • removeInputMethodListener

      default void removeInputMethodListener(InputMethodListener l)
      WARN.
    • addHierarchyListener

      default void addHierarchyListener(SHierarchyListener l)
      Wires peer attach/detach to SHierarchyEvent.HIERARCHY_CHANGED with SHierarchyEvent.DISPLAYABILITY_CHANGED / SHierarchyEvent.SHOWING_CHANGED flags set — that's the subset Vaadin surfaces cleanly. SHierarchyEvent.PARENT_CHANGED fires on attach when the new parent differs from the previous (first attach still counts).
    • removeHierarchyListener

      default void removeHierarchyListener(SHierarchyListener l)
    • getHierarchyListeners

      default SHierarchyListener[] getHierarchyListeners()
      Returns currently registered hierarchy listeners.
    • addHierarchyBoundsListener

      default void addHierarchyBoundsListener(SHierarchyBoundsListener l)
      Bucket B SHelper.onNoop(Object, String) (SD_listeners_without_analog). Vaadin doesn't surface ancestor pixel moves/resizes server-side, and R_layouts_close_enough's close-enough layout stance means a SHierarchyBoundsListener has nothing to fire on even if we tried to wire one. "Redundant by design" — same category as repaint / revalidate. getHierarchyBoundsListeners() returns an empty array.
    • removeHierarchyBoundsListener

      default void removeHierarchyBoundsListener(SHierarchyBoundsListener l)
    • getHierarchyBoundsListeners

      default SHierarchyBoundsListener[] getHierarchyBoundsListeners()
    • dispatchEvent

      default void dispatchEvent(AWTEvent e)
      Stub — programmatic event dispatch isn't wired under the Vaadin-first stance.
    • setCursor

      default void setCursor(Cursor cursor)
      Writes CSS cursor; null removes the property. Cursor.CUSTOM_CURSOR and unmapped types log and skip the CSS write (can't rasterise a custom image to a data: URL without Graphics).
    • getCursor

      default Cursor getCursor()
      Reads CSS cursor; missing property → Cursor.getDefaultCursor().
    • isShowing

      default boolean isShowing()
      true iff the component is attached to a live Vaadin UI.
    • isDisplayable

      default boolean isDisplayable()
      Deliberate no-op; surrogates are always "displayable" in the AWT-peer sense.
    • isFocusable

      default boolean isFocusable()
      Heuristic — a Focusable peer is focusable, approximation otherwise.
    • setFocusable

      default void setFocusable(boolean focusable)
      Stub — focusability isn't a settable concept in Vaadin.
    • hasFocus

      default boolean hasFocus()
      Whether this surrogate holds browser focus, read off FocusTracker's per-UI pointer (SD_focus_tracker). Same answer as isFocusOwner() — AWT's split is about temporary focus loss, which the browser does not model.
    • isFocusOwner

      default boolean isFocusOwner()
    • transferFocus

      default void transferFocus()
      Stub — AWT focus traversal isn't modelled; the browser's Tab key handles the equivalent.
    • transferFocusBackward

      default void transferFocusBackward()
      Stub.
    • transferFocusUpCycle

      default void transferFocusUpCycle()
      Stub.