Class SJDialog

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.dialog.Dialog
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

public class SJDialog extends SFrame
Surrogate for JDialog, the edit-form host.

Why extend SFrame, not a sibling SDialog

JDK shape is JDialog IS-A Dialog IS-A Window — Dialog and Frame are siblings under Window, not parent / child. The surrogate-side Window analog (SFrame) currently subsumes both the java.awt.Frame state (title, owner, defaultCloseOperation machinery via SJFrame) and the java.awt.Window state (visible shadow, listener families, owner tree). SJDialog extends SFrame to inherit that state directly rather than introducing an SDialog tier — the modal/modalityType API surface lives on :emulators.awt.Dialog (the emulator), and the Vaadin-first modality knob is reachable on every surrogate via the inherited Dialog.setModality(ModalityMode) from SWindow's parent.

R_vaadin_first stance: this surrogate doesn't reproduce the AWT setModal(boolean) / setModalityType(ModalityType) API on the surrogate side — direct surrogate users reach Vaadin's setModality natively. The emulator-layer Dialog carries the AWT-shape modal API and mirrors into Vaadin's setModality on the peer.

RootPane / contentPane / JMenuBar scaffolding

JDK shape has both JFrame and JDialog independently implementing RootPaneContainer / lazy JRootPane — inheriting from SJFrame would imply JDialog IS-A JFrame and leak that misshape into migrated code that reads dialog instanceof SJFrame. The public surface stays sibling-shaped here; the stateful machinery (lazy panes, recursion guard, menubar slot) lives single-copy on the package-private RootPaneScaffold shared with SJFrame / SJWindow — SD_sjdialog's third-consumer dedup, resolved by composition when SJWindow landed.

Default close operation

JDialog rejects EXIT_ON_CLOSE at set-time per JDK contract — unlike JFrame, JDialog can't terminate the JVM. Only DO_NOTHING_ON_CLOSE / HIDE_ON_CLOSE (default) / DISPOSE_ON_CLOSE are valid. The processWindowEvent(SWindowEvent) override layers the close-op switch on top of SWindow's standard listener dispatch — same shape as SJFrame minus the EXIT_ON_CLOSE close-time throw (since set-time already rejects it).

Content-pane mirror invariant

Same as SJFrame: dialog.getContentPane() == dialog.getRootPane().getContentPane() holds across setContentPane(Div) swaps. rootPaneCheckingEnabled routing prevents add/remove recursion during the bootstrap.
See Also:
  • Constructor Details

    • SJDialog

      public SJDialog()
      Untitled, no owner.
    • SJDialog

      public SJDialog(String title)
      Titled, no owner. Null title coerces to empty per SFrame.
    • SJDialog

      public SJDialog(SFrame owner)
      Untitled, with owner. Null owner makes this top-level.
    • SJDialog

      public SJDialog(String title, SFrame owner)
      Full ctor — forwards to SFrame(String, SFrame).
  • Method Details

    • getDefaultCloseOperation

      public int getDefaultCloseOperation()
      Current close operation; one of DO_NOTHING_ON_CLOSE / HIDE_ON_CLOSE / DISPOSE_ON_CLOSE.
    • setDefaultCloseOperation

      public void setDefaultCloseOperation(int operation)
      Validate + apply. JDialog rejects WindowConstants.EXIT_ON_CLOSE at set-time (JDK contract — only JFrame may terminate the JVM); the other three values are accepted silently. DO_NOTHING_ON_CLOSE disables the peer's ESC / outside-click dismissal so the close gesture never fires.

      Throws IllegalArgumentException on unknown values per Swing's contract (D_never_fail_on_gaps — incomplete-emulation rule doesn't scope over inputs Swing itself rejects).

    • processWindowEvent

      public void processWindowEvent(SWindowEvent e)
      JDialog-shape: let user listeners run first, then apply the default close operation. HIDE calls setVisible(false) — setVisible is idempotent, so on the native ESC / outside-click path (where SWindow.onPeerOpenedChanged(boolean) already flipped visible to false before routing here) it early-returns, while on the header close-X path (which fires WINDOW_CLOSING directly via SFrame.installHeaderCloseButton() without touching the peer's opened state) it performs the real hide. DISPOSE calls through to SWindow.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). Unlike SJFrame, no EXIT_ON_CLOSE branch — set-time rejection covers that case.
      Overrides:
      processWindowEvent in class SWindow
    • 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 throws IllegalComponentStateException; the mirror-into- rootPane invariant holds across swaps. Carried by RootPaneScaffold.
    • add

      public void add(Collection<com.vaadin.flow.component.Component> components)
    • addComponentAtIndex

      public void addComponentAtIndex(int index, com.vaadin.flow.component.Component component)
      Specified by:
      addComponentAtIndex in interface com.vaadin.flow.component.HasComponentsOfType<com.vaadin.flow.component.Component>
      Overrides:
      addComponentAtIndex in class com.vaadin.flow.component.dialog.Dialog
    • remove

      public void remove(com.vaadin.flow.component.Component... components)
    • remove

      public void remove(Collection<com.vaadin.flow.component.Component> components)
    • removeAll

      public void removeAll()
      Specified by:
      removeAll in interface com.vaadin.flow.component.HasComponentsOfType<com.vaadin.flow.component.Component>
      Overrides:
      removeAll in class com.vaadin.flow.component.dialog.Dialog
    • setJMenuBar

      public void setJMenuBar(SJMenuBar bar)
      Attach a menubar. Pass null to detach. Same idiom as SJFrame.setJMenuBar(SJMenuBar); slot semantics live on RootPaneScaffold.
    • getJMenuBar

      public SJMenuBar getJMenuBar()
      null until setJMenuBar(SJMenuBar) attaches one.
    • getRootPane

      public SJRootPane getRootPane()
      Description copied from interface: JComponentMixin
      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 JComponentMixin.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.

    • createRootPane

      protected SJRootPane createRootPane()
      Subclass hook matching JDK JDialog's createRootPane. Called once on first getRootPane() read.
    • getLayeredPane

      public com.vaadin.flow.component.Component getLayeredPane()
    • setLayeredPane

      public void setLayeredPane(com.vaadin.flow.component.Component layered)
    • getGlassPane

      public com.vaadin.flow.component.Component getGlassPane()
    • setGlassPane

      public void setGlassPane(com.vaadin.flow.component.Component glass)
    • getDefaultButton

      public com.vaadin.flow.component.button.Button getDefaultButton()
    • getUIClassID

      public String getUIClassID()
      Matches javax.swing.JDialog.getUIClassID().
    • paramString

      public String paramString()
      Extends SFrame.paramString() with the defaultCloseOperation report. Diagnostic only — not a contract users should rely on.
      Overrides:
      paramString in class SFrame