Interface JComponentMixin

All Superinterfaces:
ComponentMixin, ContainerMixin, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, Serializable
All Known Subinterfaces:
AbstractButtonMixin, JTextComponentMixin
All Known Implementing Classes:
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, SWindow

public interface JComponentMixin extends ContainerMixin
Mixin that adds the JComponent API surface on top of ContainerMixin. Under the Vaadin-first stance (SD_vaadin_first_binding), the concrete behavioural additions are:

The bulk of the JComponent surface that doesn't map to a Vaadin feature (paint pipeline, L&F, ancestor/vetoable listeners, transfer handler, focus traversal, keyboard-action dispatch, etc.) is split between SHelper.onNoop(Object, String) (redundant by design) and SHelper.onUnimplemented(Object, String, Object...) (behaviour we'd need to build). See the "Bucket B" and "Bucket C" comment headers below for the split.

Static methods on this interface are callable only via JComponentMixin.getDefaultLocale() etc. — Java interface statics aren't inherited by implementors, which matches JDK JComponent.getDefaultLocale() in practice.

  • Field Details

    • WHEN_FOCUSED

      static final int WHEN_FOCUSED
      Condition: binding fires when this component holds keyboard focus.
      See Also:
    • WHEN_ANCESTOR_OF_FOCUSED_COMPONENT

      static final int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
      Condition: binding fires when this component is an ancestor of the focused component.
      See Also:
    • WHEN_IN_FOCUSED_WINDOW

      static final int WHEN_IN_FOCUSED_WINDOW
      Condition: binding fires when this component is in the focused top-level window.
      See Also:
    • UNDEFINED_CONDITION

      static final int UNDEFINED_CONDITION
      Returned by getConditionForKeyStroke(KeyStroke) when the stroke isn't bound.
      See Also:
    • TOOL_TIP_TEXT_KEY

      static final String TOOL_TIP_TEXT_KEY
      JComponent's tooltip-text property name — this exact spelling (capital T) is what migrated PCE listeners filter on.
      See Also:
  • Method Details

    • setEnabled

      default void setEnabled(boolean enabled)
      Fires the "enabled" property change that JComponent.setEnabled fires and java.awt.Component.setEnabled does not — the whole reason this override exists at the JComponent level rather than on ComponentMixin (SD_property_fanout_audit).

      Old value is read through HasEnabled.isEnabled() (Vaadin's effective enabled), so a disabled ancestor masks the local flag — matching what user code can observe through the same getter.

      Specified by:
      setEnabled in interface ComponentMixin
      Specified by:
      setEnabled in interface com.vaadin.flow.component.HasEnabled
    • getDefaultLocale

      static Locale getDefaultLocale()
      Reads VaadinSession.getCurrent() + VaadinSession.getLocale(). Throws NullPointerException when no session is current — matches Swing's expectation that the default locale is always addressable, but honest about where it actually lives in the web model (per-session, not per-classloader AppContext).
    • setDefaultLocale

      static void setDefaultLocale(Locale locale)
      Writes through to VaadinSession.setLocale(java.util.Locale). Throws NullPointerException when no session is current — same rationale as getDefaultLocale().
    • isLightweightComponent

      static boolean isLightweightComponent(com.vaadin.flow.component.Component c)
      Returns true unconditionally — there's no heavyweight/native-peer concept in the browser, every Vaadin component is lightweight from the AWT perspective. Signature takes Vaadin's Component rather than java.awt.Component (migrated surrogates are Vaadin components, not AWT components — SD_naming signature clash rule).
    • putClientProperty

      default void putClientProperty(Object key, Object value)
      Swing contract: null value removes the mapping; firing a PropertyChangeEvent named after key.toString() when the value changes. Null key throws NullPointerException — matches JDK.
    • getClientProperty

      default Object getClientProperty(Object key)
      Null key returns null (not NPE — diverges from putClientProperty(Object, Object) on purpose, matching JDK's asymmetry). Missing keys also return null.
    • setOpaque

      default void setOpaque(boolean opaque)
      setOpaque(true) re-asserts the current background-color CSS via ComponentMixin.getBackground() (null → clear); setOpaque(false) overrides with transparent so the parent's background renders through. "opaque" PCE fires on transition so migrated MVC sees the change.

      No shadow store per R_vaadin_first — opacity state lives entirely in the rendered CSS. isOpaque() reads it back lossily: CSS background-color unset or "transparent" → false; any explicit color → true. Two accepted lossy directions:

      1. setBackground(red) on a default-opaque component flips isOpaque() from false to true, even though JDK's contract says the two are independent — under our model, "is the rendered background visible?" is what isOpaque() answers, and CSS background drives rendering regardless of the JDK flag.
      2. setOpaque(true) without a prior setBackground leaves CSS unset (we don't model UIManager's L&F default fill colour), so isOpaque() reads back as false. Callers that want true round-trip set the background first.

      setOpaque(false) → setOpaque(true) also loses the previous color (CSS at intermediate state was "transparent", which CssConvert.colorFromCss(String) reads as null). Migrators needing strict JDK round-trip register on the emulator layer (R_swing_is_truth shadow-plus-drive-peer) or re-assert setBackground after flipping back to true.

    • isOpaque

      default boolean isOpaque()
      Reads CSS background-color: unset or "transparent" → false (matches JDK JComponent default + false semantics); any other value → true. Lossy round-trip per R_vaadin_first — see setOpaque(boolean).
    • setToolTipText

      default void setToolTipText(String text)
      Overrides ContainerMixin's inherited tooltip delegation to add the "ToolTipText" PCE fire that JComponent's contract promises. Old value reads through HasTooltip.getTooltip() before the write, so listeners registered for "ToolTipText" see the before/after pair.

      No field storage (SD_vaadin_first_binding) — non-HasTooltip peers log onUnimplemented and skip the PCE since there's no value to round-trip.

      The "ToolTipText" event is the JDK's, reached by a different route: JComponent.setToolTipText has no fire of its own and gets one because it stores the text via putClientProperty, which fires key.toString(). A surrogate has no client-property table (that would be a shadow Store, R_vaadin_first), so the fire is direct here — same name, same values, and not an invented event (D_property_fanout_audit).

      Specified by:
      setToolTipText in interface ComponentMixin
    • setBorder

      default void setBorder(Border newBorder)
      Computes the effective CSS from newBorder and applies to the element, then fires "border" PCE. BorderCss.applyBorderCss(Element, Border) clears the previous border's keys first. null is a clear.

      SD_border_css_lossy: the border↔CSS round-trip is lossy — custom Border implementations, TitledBorder, and CompoundBorder with a non-EmptyBorder inner log via onUnimplemented and render nothing.

    • getBorder

      default Border getBorder()
      Reconstructs the closest Border from current CSS; null when unset. Lossy — see SD_border_css_lossy.
    • getInsets

      default Insets getInsets()
      Uses the installed border's insets when present, else zero.
    • getInsets

      default Insets getInsets(Insets insets)
      Fill-the-arg variant. Null arg allocates fresh per JDK.
    • getBounds

      default Rectangle getBounds(Rectangle rv)
      Fill-the-arg getBounds — reads from ComponentMixin.getBounds().
    • getLocation

      default Point getLocation(Point rv)
      Fill-the-arg getLocation — reads from ComponentMixin.getLocation().
    • getSize

      default Dimension getSize(Dimension rv)
      Fill-the-arg getSize — reads from ComponentMixin.getSize().
    • contains

      default boolean contains(int x, int y)
      Rectangle hit-test against ComponentMixin.getSize(). Swing's JComponent extends this to ask the UI delegate; we have no UI delegate (R_layouts_close_enough — browser owns hit-testing), so the rectangle answer is the closest honest match.
    • scrollRectToVisible

      default void scrollRectToVisible(Rectangle aRect)
      Scrolls this component into the visible browser viewport. Ignores the requested rectangle (R_best_effort_behaviour close-enough).
    • computeVisibleRect

      default void computeVisibleRect(Rectangle visibleRect)
      Fills visibleRect with (0, 0, width, height); origin is always (0, 0) under CSS flow.
    • getVisibleRect

      default Rectangle getVisibleRect()
      Returns a fresh Rectangle at origin with current size.
    • getInputMap

      default InputMap getInputMap()
      Equivalent to getInputMap(WHEN_FOCUSED).
    • getInputMap

      default InputMap getInputMap(int condition)
      Lazy-allocated InputMap for condition. Migrated code's idiomatic getInputMap().put(ks, key) round-trips through the stored map; browser-side shortcut wiring is deferred (SD_vaadin_first_binding) — registerKeyboardAction(ActionListener, KeyStroke, int) is the Bucket C WARN-stub for that.
      Throws:
      IllegalArgumentException - when condition isn't one of the three WHEN_* constants (matches JDK).
    • getActionMap

      default ActionMap getActionMap()
      Lazy-allocated ActionMap.
    • setInputMap

      default void setInputMap(int condition, InputMap map)
      Replaces the stored InputMap for condition: tears down every Vaadin shortcut we'd installed for this condition first, since the replacement map may not carry the previous bindings forward and stale shortcuts would fire on keys the InputMap no longer binds.
      Throws:
      IllegalArgumentException - on an unknown condition.
    • setActionMap

      default void setActionMap(ActionMap map)
      Replaces the stored ActionMap.
    • setInputVerifier

      default void setInputVerifier(InputVerifier v)
      Install v as the blur-time verifier. When the surrogate's peer is a BlurNotifier (most input components are), a blur subscription is installed that calls v.shouldYieldFocus; a false return restores focus via the peer's Focusable.focus() when the peer also implements that. The call routes through SHelper.callSwing(Runnable) (R_callswing_envelope) so the blocking-dialog hook lands in one place.

      Replacing or clearing the verifier tears down the previous Vaadin registration through InputVerifierStore so the user-listener fan-out stays at one verify call per blur regardless of swap count. Non-BlurNotifier peers store the verifier value (so getInputVerifier() round-trips) but no blur subscription installs — there's no browser-side event to react to. PCE fires on the "inputVerifier" property per Swing's contract.

      R_vaadin_first lossy direct binding (SD_vaadin_first_binding): JDK's InputVerifier.shouldYieldFocus(JComponent) expects a javax.swing.JComponent, which the surrogate is not. The call passes null as the source — user verifiers that read field state via input.getText() need to tolerate null on the surrogate layer (or fetch the field through a captured reference). The emulator layer (vaadinx.swing.JComponent.setInputVerifier) passes the emulator JComponent and avoids this lossiness. Migration code that ports straight to the surrogate stage and relies on the source argument needs adjustment; the typical "is this field's text valid?" pattern works fine when the verifier closes over the field.

    • getInputVerifier

      default InputVerifier getInputVerifier()
      Reads back the installed verifier. null when none is installed.
    • firePropertyChange

      default void firePropertyChange(String propertyName, char oldValue, char newValue)
      Char overload — JDK boxes for listener delivery. Complements the boolean/int overloads on ContainerMixin.
    • getAlignmentX

      default float getAlignmentX()
      Swing default is 0.5f (CENTER_ALIGNMENT).
    • getAlignmentY

      default float getAlignmentY()
    • getBaseline

      default int getBaseline(int width, int height)
      -1 means "no baseline info" per Swing's contract.
    • getBaselineResizeBehavior

      default Component.BaselineResizeBehavior getBaselineResizeBehavior()
      No baseline = OTHER.
    • isValidateRoot

      default boolean isValidateRoot()
      Swing default: false.
    • isOptimizedDrawingEnabled

      default boolean isOptimizedDrawingEnabled()
      Swing default: true.
    • isRequestFocusEnabled

      default boolean isRequestFocusEnabled()
      Swing default: true.
    • getVerifyInputWhenFocusTarget

      default boolean getVerifyInputWhenFocusTarget()
      Swing default: true.
    • isDoubleBuffered

      default boolean isDoubleBuffered()
      We don't paint (R_layouts_close_enough), so honest default is false.
    • getAutoscrolls

      default boolean getAutoscrolls()
      Swing default: false.
    • getInheritsPopupMenu

      default boolean getInheritsPopupMenu()
      Swing default: false.
    • getDebugGraphicsOptions

      default int getDebugGraphicsOptions()
      Swing's DebugGraphics.NONE_OPTION.
    • isPaintingTile

      default boolean isPaintingTile()
      Paint-internal flag; never set under R_layouts_close_enough.
    • isPaintingForPrint

      default boolean isPaintingForPrint()
      Paint-internal flag; never set under R_layouts_close_enough.
    • getComponentPopupMenu

      default SJPopupMenu getComponentPopupMenu()
      The installed component popup, or null. Pairs with setComponentPopupMenu(SJPopupMenu).
    • getTransferHandler

      default TransferHandler getTransferHandler()
      No transfer handler. Pairs with setTransferHandler(TransferHandler).
    • getNextFocusableComponent

      default com.vaadin.flow.component.Component getNextFocusableComponent()
      No deprecated next-focusable-component installed.
    • getToolTipText

      default String getToolTipText(MouseEvent event)
      JDK's location-aware tooltip variant lets a component return different tooltip text per hover point. We don't wire mouse positions server-side (R_best_effort_behaviour), so return the static tooltip — code that doesn't override stays consistent.
    • getToolTipLocation

      default Point getToolTipLocation(MouseEvent event)
      Popup location per hover; not modelled.
    • getPopupLocation

      default Point getPopupLocation(MouseEvent event)
    • createToolTip

      default JToolTip createToolTip()
      Swing's JToolTip factory — we don't model JToolTip.
    • paintImmediately

      default void paintImmediately(int x, int y, int w, int h)
      Deliberate no-op; browser repaints on DOM mutation.
    • paintImmediately

      default void paintImmediately(Rectangle r)
      Deliberate no-op.
    • getComponentGraphics

      default Graphics getComponentGraphics(Graphics g)
      Deliberate no-op; no offscreen Graphics.
    • updateUI

      default void updateUI()
      Deliberate no-op — L&F dispatch isn't modelled.
    • setUI

      default void setUI(ComponentUI ui)
      Deliberate no-op — we have no ComponentUI to install.
    • getUIClassID

      default String getUIClassID()
      Deliberate no-op — L&F key.
    • reshape

      default void reshape(int x, int y, int w, int h)
      Deprecated AWT 1.0 alias for setBounds; routes through it.
    • setAutoscrolls

      default void setAutoscrolls(boolean autoscrolls)
      Bucket B SHelper.onNoop(Object, String) — drag-autoscroll has no Vaadin counterpart.
    • setInheritsPopupMenu

      default void setInheritsPopupMenu(boolean value)
      Bucket B SHelper.onNoop(Object, String) — popup-menu inheritance not modelled.
    • setComponentPopupMenu

      default void setComponentPopupMenu(SJPopupMenu popup)
      Install (or clear) this component's context popup (SD_sjpopupmenu). Swing-flavoured helper over Vaadin's native ContextMenuBase.setTarget(Component): the popup is targeted at this component, so a right-click (or long-press) opens it. Passing null clears any previously installed popup. The stored reference (round-tripped by getComponentPopupMenu()) is backed by the live setTarget binding, not a shadow cache.
    • setRequestFocusEnabled

      default void setRequestFocusEnabled(boolean enabled)
      Bucket B SHelper.onNoop(Object, String) — focus-disable has no Vaadin counterpart.
    • setVerifyInputWhenFocusTarget

      default void setVerifyInputWhenFocusTarget(boolean value)
    • setDoubleBuffered

      default void setDoubleBuffered(boolean value)
      Bucket B SHelper.onNoop(Object, String) — we don't paint; double-buffering has nothing to apply to.
    • setDebugGraphicsOptions

      default void setDebugGraphicsOptions(int debugOptions)
      Bucket B SHelper.onNoop(Object, String) — debug-paint pipeline has no Vaadin counterpart.
    • setAlignmentX

      default void setAlignmentX(float alignmentX)
      Bucket B SHelper.onNoop(Object, String) — getters always return 0.5f (CENTER).
    • setAlignmentY

      default void setAlignmentY(float alignmentY)
    • registerKeyboardAction

      default void registerKeyboardAction(ActionListener action, KeyStroke stroke, int condition)
    • registerKeyboardAction

      default void registerKeyboardAction(ActionListener action, String command, KeyStroke stroke, int condition)
      Wraps action in an JComponentMixin.ActionStandin, stores it in the (condition) InputMap and the ActionMap, and installs a Vaadin Shortcuts listener that drives the action through SHelper.callSwing(Runnable). Unmappable strokes (keyCodes outside KeyConvert.vkToVaadinKey(int)'s table) skip the browser-side install but keep the InputMap / ActionMap entries — server-side getActionForKeyStroke still finds them.
    • unregisterKeyboardAction

      default void unregisterKeyboardAction(KeyStroke stroke)
      Remove the binding for stroke from every condition's InputMap, drop its ActionMap entry, and uninstall the matching Vaadin shortcut. Mirrors JDK's "remove across all conditions" shape.
    • resetKeyboardActions

      default void resetKeyboardActions()
      Clear every condition's InputMap, the ActionMap, and tear down every Vaadin shortcut installed via this surrogate.
    • getRegisteredKeyStrokes

      default KeyStroke[] getRegisteredKeyStrokes()
      Union of strokes registered across all three conditions.
    • getConditionForKeyStroke

      default int getConditionForKeyStroke(KeyStroke stroke)
      Walk in JDK's documented order (focused / ancestor / window) and return the first condition whose InputMap binds stroke; UNDEFINED_CONDITION when not bound anywhere.
    • getActionForKeyStroke

      default ActionListener getActionForKeyStroke(KeyStroke stroke)
      Resolve InputMap → action key → ActionMap → ActionListener. Returns null when the stroke isn't bound anywhere or the ActionMap has no entry for the key — matches JDK's "either reason → null".
    • setTransferHandler

      default void setTransferHandler(TransferHandler handler)
      WARN — drag-and-drop not modelled.
    • setNextFocusableComponent

      default void setNextFocusableComponent(com.vaadin.flow.component.Component comp)
      WARN — deprecated focus-traversal API.
    • requestDefaultFocus

      default boolean requestDefaultFocus()
      WARN — deprecated focus-traversal API.
    • setFocusTraversalKeys

      default void setFocusTraversalKeys(int id, Set<? extends AWTKeyStroke> keystrokes)
      WARN — AWT focus traversal keys not modelled (browser Tab handles equivalent).
    • addAncestorListener

      default void addAncestorListener(SAncestorListener listener)
      Wired via Vaadin attach / detach listeners. ANCESTOR_ADDED fires on attach, ANCESTOR_REMOVED on detach. ANCESTOR_MOVED (JDK fires on layout-position changes of any ancestor) is not modelled — Vaadin doesn't surface server-side layout-position events; documented as accepted incompleteness.

      Listener type retyped to SAncestorListener because JDK's javax.swing.event.AncestorEvent's ancestor / ancestorParent are typed as Container, which we can't construct against a Vaadin component (SD_event_port_stance / D_event_port_policy).

    • removeAncestorListener

      default void removeAncestorListener(SAncestorListener listener)
      Symmetric — removes both peer subscriptions wired by addAncestorListener(SAncestorListener).
    • getAncestorListeners

      default SAncestorListener[] getAncestorListeners()
      Returns the currently registered listeners in registration order.
    • addVetoableChangeListener

      default void addVetoableChangeListener(VetoableChangeListener listener)
      R_vaadin_first drop-and-WARN — see section comment.
    • removeVetoableChangeListener

      default void removeVetoableChangeListener(VetoableChangeListener listener)
      R_vaadin_first drop-and-WARN — see addVetoableChangeListener(VetoableChangeListener).
    • getVetoableChangeListeners

      default VetoableChangeListener[] getVetoableChangeListeners()
      R_vaadin_first drop-and-WARN — returns empty array.
    • fireVetoableChange

      default void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException
      R_vaadin_first drop-and-WARN — does not throw.
      Throws:
      PropertyVetoException
    • getTopLevelAncestor

      default com.vaadin.flow.component.Component getTopLevelAncestor()
      Walks the Vaadin parent chain and returns the first Dialog ancestor, or null if none — which includes the detached case and the route-level case (no enclosing Dialog). Dialog is Vaadin's closest analog to Swing's "top-level window": it owns a modal/popup frame the rest of the UI can sit inside. UI is deliberately not treated as top-level — every attached Vaadin component has a UI ancestor, so using UI would diverge from Swing's "null when no enclosing JFrame" contract.

      Handles the :emulators handoff transparently: an emulator JFrame has a Dialog peer, so a surrogate living inside that frame walks up to the Dialog and returns it. In a pure-surrogate tree (surrogate used as a plain Vaadin component under a route view, no Dialog wrapping), returns null — same as Swing would for a detached JPanel.

    • getRootPane

      default SJRootPane getRootPane()
      Walks the Vaadin parent chain and returns the first SJRootPane ancestor, or null if none. Mirrors the JDK JComponent.getRootPane() contract (climb-until-root-pane) over the surrogate-layer types.

      Surrogate-layer divergence from JDK signature: returns SJRootPane (Vaadin-rooted) rather than javax.swing.JRootPane. The same R_vaadin_first + SD_sjframe stance that drove getTopLevelAncestor() to return Vaadin Component applies here — SJRootPane is deliberately not a JDK JRootPane subclass (it extends com.vaadin.flow.component.html.Div), so a JDK-typed accessor would have to either fabricate a wrapper or stay permanently null. The Vaadin-typed accessor lets SJFrame provide a covariant override that returns its lazy-constructed pane, and lets standalone surrogates report a real ancestor when one exists. Migrators porting Swing code that read the JDK type adjust the variable type at the surrogate stage; the :emulators.JComponent.getRootPane() path keeps the JDK-typed signature for stage-2 import-swap compatibility.

    • processKeyEvent

      default void processKeyEvent(KeyEvent e)
      Bucket B SHelper.onNoop(Object, String) — ghost method. The JDK process* hooks are user-overridable dispatch entry points called by AWT's own event delivery; our event routing uses Vaadin-sourced events through the addKeyListener/addMouseListener surface and never reaches these overloads. These are onNoop rather than onUnimplemented: there's no upstream-blocked counterpart we're waiting on — these will not graduate.
    • processComponentKeyEvent

      default void processComponentKeyEvent(KeyEvent e)
    • processKeyBinding

      default boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)
    • processMouseEvent

      default void processMouseEvent(MouseEvent e)
    • processMouseMotionEvent

      default void processMouseMotionEvent(MouseEvent e)