Class SJFrame
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.dialog.Dialog
com.vaadin.swingbridge.surrogates.SWindow
com.vaadin.swingbridge.surrogates.SFrame
com.vaadin.swingbridge.surrogates.SJFrame
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasAriaRole, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasComponentsOfType<com.vaadin.flow.component.Component>, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.dialog.DialogVariant>, ComponentMixin, ContainerMixin, JComponentMixin, Serializable
Surrogate for Accessor naming —
JFrame per SD_sjframe. Extends SFrame
(the java.awt.Window + java.awt.Frame surface) and adds
the JFrame-specific layer: defaultCloseOperation +
WindowConstants surface, content-pane routing, JRootPane holder,
and the "FrameUI" L&F class id.
Why inheritance, not composition
JDK shape is JFrame IS-A Frame IS-A Window. SJFrame refines SFrame with the JRootPane + close-op + content-pane surface so the surrogate hierarchy mirrors JDK exactly: customer code that portedextends Frame → extends SFrame doesn't pay for JFrame
affordances it doesn't use; customer code that ported
extends JFrame → extends SJFrame gets the full surface.
Default close operation
HIDE (default) / DISPOSE / DO_NOTHING map cleanly onto Dialog
(setOpened(false) / removeFromParent / blocked
closeOnEsc+closeOnOutsideClick). EXIT_ON_CLOSE
is silently accepted at set-time but throws IllegalStateException
at close-time per [D_gap_severity_triage](../emulators/decisions.md#D_gap_severity_triage)'s
second throw case. The processWindowEvent(SWindowEvent) override layers the
close-op switch on top of SWindow's standard listener
dispatch.
Content-pane routing
JFrame's post-Java-5 contract:frame.add(child) routes into the
content pane. We reproduce this by overriding the Dialog
add/remove family to redirect into a lazy Div contentPane. The
stateful machinery (lazy panes, the rootPaneCheckingEnabled
recursion guard, menubar slot) lives single-copy on the package-private
RootPaneScaffold shared with SJDialog / SJWindow.
Accessor naming — getRootPane()
JComponentMixin.getRootPane() returns
SJRootPane on the surrogate layer (the inherited signature
carries no type collision with
javax.swing.JRootPane — SJRootPane is the
surrogate-layer root-pane type, and the mixin's walk-and-return
surface this directly). SJFrame overrides getRootPane() to
return its own lazy-constructed pane rather than walking parents,
matching JDK JFrame's "I am the root-pane host" semantics.
Lazy rootPane construction
AWT contract: JRootPane accessors are lazy — most JFrames never reach throughgetRootPane(), and eager construction would
allocate three panes per frame for nothing. getRootPane()
constructs on first read via createRootPane(); the factory
is a subclass hook matching JDK JFrame's override point. Before
first read, the root pane is null and setContentPane(Div)
doesn't force-construct it — the setter just updates this class's
own contentPane Div, and the lazy seed at first read picks up the
current contentPane.
Content-pane mirror invariant
Migrated code that alternatesframe.getContentPane() and
frame.getRootPane().getContentPane() expects both to report
the same Div across content-pane swaps. setContentPane(Div)
mirrors the reference into any already-constructed rootPane.
Mirror-on-write beats a listener subscription — content pane swaps
are rare and cheap to bridge explicitly.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.dialog.Dialog
com.vaadin.flow.component.dialog.Dialog.ClosedEvent, com.vaadin.flow.component.dialog.Dialog.DialogCloseActionEvent, com.vaadin.flow.component.dialog.Dialog.DialogDraggedEvent, com.vaadin.flow.component.dialog.Dialog.DialogFooter, com.vaadin.flow.component.dialog.Dialog.DialogHeader, com.vaadin.flow.component.dialog.Dialog.DialogResizeEvent, com.vaadin.flow.component.dialog.Dialog.OpenedChangeEventNested classes/interfaces inherited from interface JComponentMixin
JComponentMixin.ActionStandin -
Field Summary
Fields inherited from interface JComponentMixin
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Collection<com.vaadin.flow.component.Component> components) Route into content pane while the scaffold's checking flag is set.voidaddComponentAtIndex(int index, com.vaadin.flow.component.Component component) Route into content pane while the scaffold's checking flag is set.protected SJRootPaneSubclass hook matching JDK JFrame'screateRootPane.com.vaadin.flow.component.html.DivLazy-creates if never accessed.com.vaadin.flow.component.button.ButtonConvenience accessor:getRootPane().getDefaultButton().intCurrent close operation; one ofWindowConstants's four values.com.vaadin.flow.component.ComponentDelegates togetRootPane().getGlassPane().nulluntilsetJMenuBar(SJMenuBar)attaches one.com.vaadin.flow.component.ComponentDelegates togetRootPane().getLayeredPane().Lazy-constructs viacreateRootPane()on first read (the scaffold captures the hook and seeds the SD_sjframe mirror invariant).Matchesjavax.swing.JFrame.getUIClassID().ExtendsSFrame.paramString()with the defaultCloseOperation report.voidJFrame-shape: let user listeners run first (they may callSystem.exitor otherwise short-circuit), then apply the default close operation.voidremove(com.vaadin.flow.component.Component... components) Route into content pane while the scaffold's checking flag is set.voidremove(Collection<com.vaadin.flow.component.Component> components) Route into content pane while the scaffold's checking flag is set.voidRoute into content pane while the scaffold's checking flag is set.voidsetContentPane(com.vaadin.flow.component.html.Div newPane) Swap the content pane.voidsetDefaultCloseOperation(int operation) Validate + apply.voidsetGlassPane(com.vaadin.flow.component.Component glass) Delegates togetRootPane().setGlassPane(...).voidsetJMenuBar(SJMenuBar bar) Attach a menubar to this frame.voidsetLayeredPane(com.vaadin.flow.component.Component layered) Delegates togetRootPane().setLayeredPane(...).voidsetRootPane(SJRootPane root) Replaces the root pane, as the JDK's protectedsetRootPanedoes: the outgoing one leaves this window androotbecomes its one child, holding the content pane from then on.Methods inherited from class SFrame
getExtendedState, getFrames, getOwnerlessFrames, getState, getTitle, isDefaultLookAndFeelDecorated, isResizable, isUndecorated, setDefaultLookAndFeelDecorated, setExtendedState, setResizable, setState, setTitle, setUndecoratedMethods inherited from class SWindow
addComponentListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, centerOnScreen, createBufferStrategy, createBufferStrategy, dispose, fireClosedEvent, fireClosingEvent, fireOpenedEvent, fireWindowEvent, fireWindowFocusEvent, fireWindowStateEvent, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isUndecoratedChrome, isValidateRoot, pack, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setAutoRequestFocus, setBounds, setEnabled, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocationByPlatform, setLocationRelativeTo, setOpacity, setShape, setSize, setUndecoratedChrome, setVisible, toBack, toFrontMethods inherited from class com.vaadin.flow.component.dialog.Dialog
addAttachListener, addClosedListener, addDetachListener, addDialogCloseActionListener, addDraggedListener, addOpenedChangeListener, addResizeListener, bindChildren, bindHeight, bindVisible, bindWidth, close, getAriaLabel, getChildren, getFooter, getHeader, getHeaderTitle, getHeight, getLeft, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getModality, getOverlayRole, getRole, getStyle, getTop, getWidth, isAutofocus, isCloseOnEsc, isCloseOnOutsideClick, isDraggable, isFocusTrap, isKeepInViewport, isModal, isOpened, onAttach, open, setAriaLabel, setAutofocus, setCloseOnEsc, setCloseOnOutsideClick, setDraggable, setFocusTrap, setHeaderTitle, setHeight, setKeepInViewport, setLeft, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setModal, setModality, setOpened, setOverlayRole, setRole, setTop, setWidthMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, whenAttachedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ComponentMixin
_installSwingClass, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, dispatchEvent, doLayout, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getComponentListeners, getCursor, getFocusListeners, getFont, getForeground, getGraphics, getHierarchyBoundsListeners, getHierarchyListeners, getKeyListeners, getLocation, getMaximumSize, getMinimumSize, getMouseListeners, getName, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolTipText, getX, getY, grabFocus, hasFocus, invalidate, isDisplayable, isFocusable, isFocusOwner, isShowing, paint, paintAll, print, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, revalidate, setBackground, setBounds, setCursor, setFocusable, setFont, setForeground, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validateMethods inherited from interface ContainerMixin
addContainerListener, getContainerListeners, getLayout, paintComponents, printComponents, removeContainerListener, setLayoutMethods inherited from interface com.vaadin.flow.component.HasAriaRole
getAriaRole, setAriaRoleMethods inherited from interface com.vaadin.flow.component.HasComponents
addMethods inherited from interface com.vaadin.flow.component.HasComponentsOfType
add, addComponentAsFirst, getComponentAt, getComponentCount, indexOf, replaceMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, bindThemeVariant, bindThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariantsMethods inherited from interface JComponentMixin
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, isDoubleBuffered, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paintImmediately, paintImmediately, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, requestDefaultFocus, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDoubleBuffered, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, updateUI
-
Constructor Details
-
SJFrame
public SJFrame()Untitled, no owner. -
SJFrame
Titled, no owner. Null title coerces to empty per SFrame. -
SJFrame
Untitled, with owner. Null owner makes this top-level. -
SJFrame
Full ctor — forwards toSFrame(String, SFrame).
-
-
Method Details
-
getDefaultCloseOperation
public int getDefaultCloseOperation()Current close operation; one ofWindowConstants's four values. -
setDefaultCloseOperation
public void setDefaultCloseOperation(int operation) Validate + apply. All fourWindowConstantsvalues are accepted silently at set-time. The throw trigger forEXIT_ON_CLOSEfires at close-time (per [D_gap_severity_triage](../emulators/decisions.md#D_gap_severity_triage)'s second case):processWindowEvent(SWindowEvent)throwsIllegalStateExceptionwhen a peer-originated close-attempt lands while the op isEXIT_ON_CLOSE, so the migrator's "terminate" intent is surfaced rather than silently ignored.DO_NOTHING_ON_CLOSEdisables the peer's ESC / outside-click dismissal so the close gesture never fires.Throws
IllegalArgumentExceptionon unknown values per Swing's contract (D_never_fail_on_gaps — incomplete-emulation rule doesn't scope over inputs Swing itself rejects). -
processWindowEvent
JFrame-shape: let user listeners run first (they may callSystem.exitor otherwise short-circuit), then apply the default close operation. HIDE callssetVisible(false)—setVisibleis idempotent, so on the native ESC / outside-click path (whereSWindow.onPeerOpenedChanged(boolean)already flippedvisibleto false before routing here) it early-returns, while on the header close-X path (which firesWINDOW_CLOSINGdirectly viaSFrame.installHeaderCloseButton()without touching the peer's opened state) it performs the real hide; DISPOSE calls through toSWindow.dispose()for the detach +WINDOW_CLOSED; DO_NOTHING is a genuine no-op (the window must stay open even when the close-X — which is never disarmed — delivers the event).EXIT_ON_CLOSEthrowsIllegalStateExceptionper [D_gap_severity_triage](../emulators/decisions.md#D_gap_severity_triage)'s second throw case. The exception propagates per R_callswing_envelope to Vaadin'sErrorHandler; the dialog stays visually closed because the peer already closed before we got the close event, but the throw surfaces the migrator's "terminate the JVM" intent rather than letting it silently noop. A later revision may swap this to close the Vaadin session instead.- Overrides:
processWindowEventin classSWindow
-
getContentPane
public com.vaadin.flow.component.html.Div getContentPane()Lazy-creates if never accessed. Never returns null. -
setContentPane
public void setContentPane(com.vaadin.flow.component.html.Div newPane) Swap the content pane. JDK contract: null throwsIllegalComponentStateException; existing children are NOT migrated; the SD_sjframe mirror invariant (frame.getContentPane() == frame.getRootPane().getContentPane()) holds across swaps. All carried byRootPaneScaffold. -
add
Route into content pane while the scaffold's checking flag is set. -
addComponentAtIndex
public void addComponentAtIndex(int index, com.vaadin.flow.component.Component component) Route into content pane while the scaffold's checking flag is set.- Specified by:
addComponentAtIndexin interfacecom.vaadin.flow.component.HasComponentsOfType<com.vaadin.flow.component.Component>- Overrides:
addComponentAtIndexin classcom.vaadin.flow.component.dialog.Dialog
-
remove
public void remove(com.vaadin.flow.component.Component... components) Route into content pane while the scaffold's checking flag is set. -
remove
Route into content pane while the scaffold's checking flag is set. -
removeAll
public void removeAll()Route into content pane while the scaffold's checking flag is set. Otherwise delegate to Dialog'sremoveAll(which iterates children manually to preserve the overlay's slot elements).- Specified by:
removeAllin interfacecom.vaadin.flow.component.HasComponentsOfType<com.vaadin.flow.component.Component>- Overrides:
removeAllin classcom.vaadin.flow.component.dialog.Dialog
-
setJMenuBar
Attach a menubar to this frame. Passnullto detach. Slot semantics (index 0, sibling of the content pane, detach-old- first) live onRootPaneScaffold. -
getJMenuBar
nulluntilsetJMenuBar(SJMenuBar)attaches one. -
getRootPane
Lazy-constructs viacreateRootPane()on first read (the scaffold captures the hook and seeds the SD_sjframe mirror invariant). Covariant override ofJComponentMixin.getRootPane()— SJFrame returns its own held pane rather than walking parents. -
setRootPane
Replaces the root pane, as the JDK's protectedsetRootPanedoes: the outgoing one leaves this window androotbecomes its one child, holding the content pane from then on. Public so the emulator layer can hand down the peer of the root pane it built itself, which is how one root pane serves both layers.- Parameters:
root-nullleaves the window without a root pane, as the JDK allows
-
createRootPane
Subclass hook matching JDK JFrame'screateRootPane. Called once on firstgetRootPane()read. Subclasses can override to supply a customSJRootPane; the default returns a plain one. -
getLayeredPane
public com.vaadin.flow.component.Component getLayeredPane()Delegates togetRootPane().getLayeredPane(). -
setLayeredPane
public void setLayeredPane(com.vaadin.flow.component.Component layered) Delegates togetRootPane().setLayeredPane(...). -
getGlassPane
public com.vaadin.flow.component.Component getGlassPane()Delegates togetRootPane().getGlassPane(). -
setGlassPane
public void setGlassPane(com.vaadin.flow.component.Component glass) Delegates togetRootPane().setGlassPane(...). -
getDefaultButton
public com.vaadin.flow.component.button.Button getDefaultButton()Convenience accessor:getRootPane().getDefaultButton(). -
getUIClassID
Matchesjavax.swing.JFrame.getUIClassID(). -
paramString
ExtendsSFrame.paramString()with the defaultCloseOperation report. Diagnostic only — not a contract users should rely on.- Overrides:
paramStringin classSFrame
-