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
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 Summary
Modifier and TypeMethodDescriptiondefault voidStampdata-swing-classon this surrogate's element using its runtime class.default voidaddComponentListener(SComponentListener listener) Registers the listener viaRegistrationsand wires the peer's attach/detach events to dispatchSComponentEvent.COMPONENT_SHOWNandSComponentEvent.COMPONENT_HIDDEN.default voidRegisters withFocusNotifier/BlurNotifierwhen the peer supports them, dispatchingSFocusEventvia the user'sSFocusListener.default voidBucket BSHelper.onNoop(Object, String)(SD_listeners_without_analog).default voidWires peer attach/detach toSHierarchyEvent.HIERARCHY_CHANGEDwithSHierarchyEvent.DISPLAYABILITY_CHANGED/SHierarchyEvent.SHOWING_CHANGEDflags set — that's the subset Vaadin surfaces cleanly.default voidWARN — input-method events have no web equivalent.default voidRegisters withKeyNotifierwhen the peer supports it, dispatchingSKeyEventvia the user'sSKeyListener.default voidRegisters with VaadinClickNotifierwhen the peer supports it, dispatchingSMouseEvent.MOUSE_CLICKEDvia the user'sSMouseListener.mouseClicked(SMouseEvent).default voidWARN — Vaadin has no server-side mouse-motion event source.default voidWARN — Vaadin has no server-side mouse-wheel event source.default voidDeliberate no-op; AWT native-peer lifecycle has no Vaadin analog.default voidBacked by per-componentPropertyChangeSupportviaPceSupport.default voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Name-filtered registration —PropertyChangeSupporthandles the name dispatch internally.default voidStub — programmatic event dispatch isn't wired under the Vaadin-first stance.default voiddoLayout()Deliberate no-op; layout is browser-driven.default voidfirePropertyChange(String propertyName, boolean oldValue, boolean newValue) Boolean overload.default voidfirePropertyChange(String propertyName, int oldValue, int newValue) Int overload.default voidfirePropertyChange(String propertyName, Object oldValue, Object newValue) Fires to registered listeners.default ColorReconstructs the backgroundColorfrom CSSbackground-color.default Rectangle(0, 0, width, height)— origin is always (0, 0) since we have no server-side pixel coordinate.default SComponentListener[]Returns the currently registeredSComponentListeners in registration order.default CursorReads CSScursor; missing property →Cursor.getDefaultCursor().default SFocusListener[]Returns currently registered focus listeners in registration order.default FontgetFont()default Colordefault GraphicsReturnsnull— no offscreen Graphics exists for a Vaadin component.default SHierarchyBoundsListener[]Always an empty array — seeaddHierarchyBoundsListener(SHierarchyBoundsListener).default SHierarchyListener[]Returns currently registered hierarchy listeners.default SKeyListener[]Returns currently registered key listeners in registration order.default PointOrigin — chained reads don't NPE.default DimensionSeegetPreferredSize().default DimensionSeegetPreferredSize().default SMouseListener[]Returns currently registered mouse listeners in registration order.default StringgetName()Reads theNameStoreslot.default DimensionReads the single HasSize dimension — same valuegetSize()returns.default PropertyChangeListener[]Returns all listeners — general + name-filtered wrappers per JDK contract.default PropertyChangeListener[]getPropertyChangeListeners(String propertyName) Returns only listeners registered for the given property name.default DimensiongetSize()ReadsHasSizeback; non-pixel values fall back to 1 (seeCssConvert.parsePxOr1(String)).default StringReads fromHasTooltip.getTooltip(); non-HasTooltip peers log and returnnull.default intgetX()Bucket B — seesetLocation(int, int).default intgetY()Bucket B — seesetLocation(int, int).default voidSwing'sgrabFocusis "request focus and force it"; Vaadin has no force option.default booleanhasFocus()Whether this surrogate holds browser focus, read offFocusTracker's per-UI pointer (SD_focus_tracker).default voidDeliberate no-op.default booleanDeliberate no-op; surrogates are always "displayable" in the AWT-peer sense.default booleanHeuristic — aFocusablepeer is focusable, approximation otherwise.default booleanSeehasFocus().default booleantrueiff the component is attached to a live VaadinUI.default voidDeliberate no-op; noGraphicsto paint into.default voidDeliberate no-op.default voidDeliberate no-op.default voidDeliberate no-op.default voidremoveComponentListener(SComponentListener listener) Symmetric — removes both peer subscriptions wired byaddComponentListener(SComponentListener).default voidSymmetric — removes the wired Vaadin subscriptions.default voidBucket BSHelper.onNoop(Object, String).default voidSymmetric toaddHierarchyListener(SHierarchyListener).default voidWARN.default voidSymmetric — removes all three wired Vaadin subscriptions.default voidSymmetric — removes the wired Vaadin subscription.default voidWARN — seeaddMouseMotionListener(MouseMotionListener).default voidWARN — seeaddMouseWheelListener(MouseWheelListener).default voidDeliberate no-op.default voidRemoves a previously registered general listener.default voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Removes listeners registered with the matching property name.default voidrepaint()Deliberate no-op; the browser repaints when the DOM changes.default voidrepaint(int x, int y, int w, int h) Region repaint.default voidrepaint(long tm) Timed-repaint variant.default voidrepaint(long tm, int x, int y, int w, int h) Timed region repaint.default voidRectangleregion repaint.default voidVaadin's analog isFocusable.focus().default booleanrequestFocus(boolean temporary) Returnstrueunconditionally — Vaadin'sfocus()is fire-and-forget.default voidSame path asrequestFocus().default booleanrequestFocusInWindow(boolean temporary) default voidDeliberate no-op; Vaadin has no Swing-style validate cycle.default voidCSSbackground-color.default voidsetBounds(int x, int y, int width, int height) See class-level "Bucket A" — x/y can't be honoured under CSS flow; logs viaSHelper.onNoop(Object, String).default voidRectangleoverload.default voidWrites CSScursor;nullremoves the property.default voidsetEnabled(boolean enabled) OverridesHasEnabled.setEnabled(boolean)for the no-op-on-equal guard.default voidsetFocusable(boolean focusable) Stub — focusability isn't a settable concept in Vaadin.default voidWrites the full font quartet on every set so a previoussetFont's leftover style fragments don't bleed through.default voidWrites CSScolor.default voidsetLocation(int x, int y) Bucket BSHelper.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).default voidsetLocation(Point p) Pointoverload — seesetLocation(int, int).default voiddefault voiddefault voidWrites toNameStoreonly — deliberately does not touch Vaadin'ssetId.default voidRoutes tosetSize(Dimension).default voidsetSize(int width, int height) Writes pixel dimensions viaHasSizein"Npx"form.default voidDimensionoverload;nullis onNoop.default voidsetToolTipText(String text) Delegates directly to Vaadin'sHasTooltip.setTooltipText(String).default voidStub — AWT focus traversal isn't modelled; the browser's Tab key handles the equivalent.default voidStub.default voidStub.default voidDeliberate no-op.default voidvalidate()Deliberate no-op.Methods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
-
Method Details
-
getName
-
setName
Writes toNameStoreonly — deliberately does not touch Vaadin'ssetId. 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-nameDOM attribute so the value is visible in DevTools without exposing it throughid(which would force uniqueness Swing's name doesn't have). Cleared when name isnull/ blank.Fires
"name"PCE per Swing's Component contract (SD_auto_pce). -
_installSwingClass
default void _installSwingClass()Stampdata-swing-classon 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) OverridesHasEnabled.setEnabled(boolean)for the no-op-on-equal guard. Fires no"enabled"property change:java.awt.Component.setEnableddelegates to the deprecatedenable(), which fires onlyAccessibleContext.ACCESSIBLE_STATE_PROPERTYon the accessible context's own listener list — nothing acomponent.addPropertyChangeListenerever sees. The bound"enabled"property isJComponentMixin'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:
setEnabledin interfacecom.vaadin.flow.component.HasEnabled
-
setToolTipText
Delegates directly to Vaadin'sHasTooltip.setTooltipText(String). Non-HasTooltip peers log viaSHelper.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
Reads fromHasTooltip.getTooltip(); non-HasTooltip peers log and returnnull. No server-side store: the tooltip value is whatever the peer currently carries. -
requestFocus
default void requestFocus()Vaadin's analog isFocusable.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) Returnstrueunconditionally — Vaadin'sfocus()is fire-and-forget. Matches the AWT default of "we tried, we don't know." -
requestFocusInWindow
default void requestFocusInWindow()Same path asrequestFocus(). -
requestFocusInWindow
default boolean requestFocusInWindow(boolean temporary) -
grabFocus
default void grabFocus()Swing'sgrabFocusis "request focus and force it"; Vaadin has no force option. -
getForeground
-
setForeground
Writes CSScolor.nullremoves 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 throughgetForeground()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
-
setBackground
CSSbackground-color.nullremoves the property. Fires"background"PCE per Swing's Component contract (SD_auto_pce). -
getFont
Reconstructs aFontfrom the four CSS slots (font-family/font-size/font-weight/font-style). Lossy — see class-level Javadoc. When no font CSS is set, returnsCssConvert.DEFAULT_FONTrather thannull: real Swing installs an L&F default font at construction, sogetFont()is non-null, and the ubiquitous GUI-builder idiomgetFont().deriveFont(...)relies on it. Callers that need the local-only "was a font explicitly set" answer read thefont-*style slots directly rather than diffing against this default. -
setFont
Writes the full font quartet on every set so a previoussetFont's leftover style fragments don't bleed through.nullremoves all four for parent-inheritance.Fires
"font"PCE per Swing's Component contract (SD_auto_pce). Old-value comes fromgetFont()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
Backed by per-componentPropertyChangeSupportviaPceSupport. -
addPropertyChangeListener
Name-filtered registration —PropertyChangeSupporthandles the name dispatch internally. -
removePropertyChangeListener
Removes a previously registered general listener. -
removePropertyChangeListener
Removes listeners registered with the matching property name. -
getPropertyChangeListeners
Returns all listeners — general + name-filtered wrappers per JDK contract. -
getPropertyChangeListeners
Returns only listeners registered for the given property name. -
firePropertyChange
Fires to registered listeners.setName(String),setEnabled(boolean),setForeground(Color),setBackground(Color),setFont(Font)all auto-fire under this path (SD_auto_pce). -
firePropertyChange
Boolean overload. -
firePropertyChange
Int overload. -
addComponentListener
Registers the listener viaRegistrationsand wires the peer's attach/detach events to dispatchSComponentEvent.COMPONENT_SHOWNandSComponentEvent.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
Symmetric — removes both peer subscriptions wired byaddComponentListener(SComponentListener). -
getComponentListeners
Returns the currently registeredSComponentListeners 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 viaSHelper.onNoop(Object, String). -
setBounds
-
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 viaHasSizein"Npx"form. -
setSize
-
getSize
ReadsHasSizeback; non-pixel values fall back to 1 (seeCssConvert.parsePxOr1(String)). -
setLocation
default void setLocation(int x, int y) Bucket BSHelper.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 isonNooprather thanonUnimplemented: there is no upstream-blocked counterpart we are waiting on, so a WARN would be misleading. -
setLocation
Pointoverload — seesetLocation(int, int). -
getLocation
Origin — chained reads don't NPE. -
getX
default int getX()Bucket B — seesetLocation(int, int). -
getY
default int getY()Bucket B — seesetLocation(int, int). -
setPreferredSize
Routes tosetSize(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 whatgetMinimumSize()andgetMaximumSize()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. SeesizeBefore()for how the old value reproduces AWT's null-for-unset without a shadow flag. -
getPreferredSize
-
setMinimumSize
-
getMinimumSize
SeegetPreferredSize(). -
setMaximumSize
-
getMaximumSize
SeegetPreferredSize(). -
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
-
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
-
update
Deliberate no-op. -
paintAll
Deliberate no-op. -
print
Deliberate no-op. -
printAll
Deliberate no-op. -
getGraphics
Returnsnull— 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
Registers withFocusNotifier/BlurNotifierwhen the peer supports them, dispatchingSFocusEventvia the user'sSFocusListener. Non-focusable peers log and skip wiring — there's nothing useful to listen to. -
removeFocusListener
Symmetric — removes the wired Vaadin subscriptions. -
getFocusListeners
Returns currently registered focus listeners in registration order. -
addKeyListener
Registers withKeyNotifierwhen the peer supports it, dispatchingSKeyEventvia the user'sSKeyListener. Non-KeyNotifierpeers 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 throughSHelper.callSwing(Runnable)(R_callswing_envelope) so the blocking-dialog hook lands in one place. See SD_key_events for the mapping rationale. -
removeKeyListener
Symmetric — removes all three wired Vaadin subscriptions. -
getKeyListeners
Returns currently registered key listeners in registration order. -
addMouseListener
Registers with VaadinClickNotifierwhen the peer supports it, dispatchingSMouseEvent.MOUSE_CLICKEDvia the user'sSMouseListener.mouseClicked(SMouseEvent). Non-ClickNotifierpeers logSHelper.onUnimplemented(Object, String, Object...)and skip wiring.Partial coverage. Only
mouseClickedfires 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 thataddKeyListener(SKeyListener)takes by covering only theKeyNotifiersubset of the JDK key surface.addMouseMotionListenerandaddMouseWheelListenerstay 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_MASKbits; button mapping is Vaadin-DOM (0/1/2 left/middle/right) →SMouseEvent.BUTTON1/BUTTON2/BUTTON3, with unknown (-1) reading asSMouseEvent.NOBUTTON. -
removeMouseListener
Symmetric — removes the wired Vaadin subscription. -
getMouseListeners
Returns currently registered mouse listeners in registration order. -
addMouseMotionListener
WARN — Vaadin has no server-side mouse-motion event source. -
removeMouseMotionListener
WARN — seeaddMouseMotionListener(MouseMotionListener). -
addMouseWheelListener
WARN — Vaadin has no server-side mouse-wheel event source. -
removeMouseWheelListener
WARN — seeaddMouseWheelListener(MouseWheelListener). -
addInputMethodListener
WARN — input-method events have no web equivalent. -
removeInputMethodListener
WARN. -
addHierarchyListener
Wires peer attach/detach toSHierarchyEvent.HIERARCHY_CHANGEDwithSHierarchyEvent.DISPLAYABILITY_CHANGED/SHierarchyEvent.SHOWING_CHANGEDflags set — that's the subset Vaadin surfaces cleanly.SHierarchyEvent.PARENT_CHANGEDfires on attach when the new parent differs from the previous (first attach still counts). -
removeHierarchyListener
Symmetric toaddHierarchyListener(SHierarchyListener). -
getHierarchyListeners
Returns currently registered hierarchy listeners. -
addHierarchyBoundsListener
Bucket BSHelper.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 aSHierarchyBoundsListenerhas nothing to fire on even if we tried to wire one. "Redundant by design" — same category asrepaint/revalidate.getHierarchyBoundsListeners()returns an empty array. -
removeHierarchyBoundsListener
Bucket BSHelper.onNoop(Object, String). -
getHierarchyBoundsListeners
Always an empty array — seeaddHierarchyBoundsListener(SHierarchyBoundsListener). -
dispatchEvent
Stub — programmatic event dispatch isn't wired under the Vaadin-first stance. -
setCursor
Writes CSScursor;nullremoves the property.Cursor.CUSTOM_CURSORand unmapped types log and skip the CSS write (can't rasterise a custom image to adata:URL without Graphics). -
getCursor
Reads CSScursor; missing property →Cursor.getDefaultCursor(). -
isShowing
default boolean isShowing()trueiff the component is attached to a live VaadinUI. -
isDisplayable
default boolean isDisplayable()Deliberate no-op; surrogates are always "displayable" in the AWT-peer sense. -
isFocusable
default boolean isFocusable()Heuristic — aFocusablepeer 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 offFocusTracker's per-UI pointer (SD_focus_tracker). Same answer asisFocusOwner()— AWT's split is about temporary focus loss, which the browser does not model. -
isFocusOwner
default boolean isFocusOwner()SeehasFocus(). -
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.
-