Class JFrame

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, WindowConstants, RootPaneContainer

public class JFrame extends Frame implements WindowConstants, Accessible, RootPaneContainer
Emulator for JFrame. Per D_jframe_as_route, a JFrame's rendering shape is selected at construction via FrameStrategy: DialogStrategy (regular JFrame, peer is SJFrame) or InlineStrategy (@MainWindow-annotated, peer is SJPanel, attached to a MainWindowRoute).

R_leaf_peer_lockdown-locked-down: no protected (Component peer) ctor — every public ctor funnels through a private (FrameStrategy) ctor that hard-codes the strategy's peer type. The framework selects among SJFrame/SJPanel based on the @MainWindow annotation per D_framework_peer_selection; user code cannot influence the choice.

See Also:
  • Field Details

    • rootPane

      protected JRootPane rootPane
    • rootPaneCheckingEnabled

      protected boolean rootPaneCheckingEnabled
  • Constructor Details

  • Method Details

    • frameInit

      protected void frameInit()
      The JDK's own body (JFrame.java:255), line for line: enable the window event masks, take the default locale, build the root pane through createRootPane() and plant it via setRootPane(JRootPane), take the L&F control background, then turn root-pane checking on — each as a call, so a subclass override of any hook actually runs (R_no_vaadin_in_api limb 2). The frame's single child is the root pane; everything else hangs off it.

      Two of those lines land on deliberate nothings, and the nothings are where the fidelity is: enableEvents no-ops because dispatch is already unconditional, and UIManager.controlColor() is null because L&F is out of scope. Both still *run*, so a migrator's setBackground override fires from the constructor exactly as on the desktop.

    • pack

      public void pack()
      Window.pack() hook for the inline-strategy route-sizing model — default path is a no-op (PWA shape: route stays setSizeFull, SJPanel stays width:100% / height:100% pinned by setPreferredSize(Dimension) below). The setResizable(false) + setPreferredSize + pack() opt-out path runs the route-shrink + pixel-write in InlineStrategy.applyInlineSizingOnPack(JFrame). Per D_inline_route_sizing. DialogStrategy retains the inherited onNoop behaviour (Dialog peer auto-sizes regardless).
      Overrides:
      pack in class Window
    • setPreferredSize

      public void setPreferredSize(Dimension preferredSize)
      Overrides Component.setPreferredSize(Dimension) for the InlineStrategy PWA-shape default: a @MainWindow JFrame fills the viewport regardless of the user's preferred-size request. Super still field-shadows the value and fires PCE, so getPreferredSize() round-trips per R_swing_is_truth; we re-pin width:100% / height:100% over the parent's pixel write. The setResizable(false) carve-out lets the parent's pixel write stand for fixed-size main windows. DialogStrategy bypasses this branch — Dialog peer sizing is driven by Component.setPreferredSize verbatim. Per D_inline_route_sizing.
      Overrides:
      setPreferredSize in class Component
    • getContentPane

      public Container getContentPane()
      Delegates to the root pane, as the JDK's does (JFrame.java:645).
      Specified by:
      getContentPane in interface RootPaneContainer
    • setContentPane

      public void setContentPane(Container newPane)
      Delegates to the root pane, as the JDK's does (JFrame.java:668) — so frame.getContentPane() and frame.getRootPane().getContentPane() are the same pane by construction rather than by a mirror that has to be kept in step.
      Specified by:
      setContentPane in interface RootPaneContainer
    • addImpl

      protected void addImpl(Component comp, Object constraints, int index)
      Overrides:
      addImpl in class Container
    • setLayout

      public void setLayout(LayoutManager manager)
      Description copied from class: Window
      Stores the manager and invalidates as AWT does, minus the CSS dispatch — see Window.windowLayout.
      Overrides:
      setLayout in class Window
      Parameters:
      manager - may be null, as AWT allows
    • remove

      public void remove(Component comp)
      Overrides:
      remove in class Container
    • setRootPaneCheckingEnabled

      protected void setRootPaneCheckingEnabled(boolean enabled)
    • isRootPaneCheckingEnabled

      protected boolean isRootPaneCheckingEnabled()
      Whether add / remove / setLayout redirect into the content pane. The redirect consults this method rather than the field, so a subclass override is honoured (R_no_vaadin_in_api second limb, D_r12_provenance).
    • getRootPane

      public JRootPane getRootPane()
      Specified by:
      getRootPane in interface RootPaneContainer
    • setRootPane

      protected void setRootPane(JRootPane newRootPane)
      The JDK's body (JFrame.java:613): remove the outgoing root pane, then add the incoming one. Runs with root-pane checking cleared so addImpl(Component, Object, int)'s redirect falls through to Container's rather than routing the new root pane into the old one's content pane.
    • createRootPane

      protected JRootPane createRootPane()
    • getLayeredPane

      public JLayeredPane getLayeredPane()
      Specified by:
      getLayeredPane in interface RootPaneContainer
    • setLayeredPane

      public void setLayeredPane(JLayeredPane layered)
      Specified by:
      setLayeredPane in interface RootPaneContainer
    • getGlassPane

      public Component getGlassPane()
      Specified by:
      getGlassPane in interface RootPaneContainer
    • setGlassPane

      public void setGlassPane(Component glass)
      Specified by:
      setGlassPane in interface RootPaneContainer
    • update

      public void update(Graphics arg0)
      Overrides:
      update in class Container
    • paramString

      protected String paramString()
      Overrides:
      paramString in class Frame
    • processWindowEvent

      protected void processWindowEvent(WindowEvent e)
      AWT's Window.processWindowEvent routes WINDOW_CLOSING to registered listeners; we extend that here to also apply the default close operation after the user's listeners have run. Running super first matches Swing's ordering — if a WindowListener calls System.exit or otherwise short-circuits the app, the default op doesn't get a chance to interfere.

      Per D_close_operation_dispatch, close-op dispatch differs by strategy:

      • DialogStrategy: EXIT_ON_CLOSE throws IllegalStateException per D_gap_severity_triage case 2.
      • InlineStrategy disposes on EXIT_ON_CLOSE; the session then ends through AutoShutdown if that took the app's last displayable window (D_auto_shutdown).
      • DISPOSE_ON_CLOSE calls Window.dispose(); HIDE / DO_NOTHING are no-ops in both strategies (HIDE is already effectively done by the time we get here, and DO_NOTHING doesn't reach us in practice — setter disarms the peer's close gestures).
      Overrides:
      processWindowEvent in class Window
    • applyVisibleToPeerImpl

      protected void applyVisibleToPeerImpl(boolean b)
      Strategy hook for Window.show() / Window.hide() — delegates the peer-side write through FrameStrategy.applyVisibleToPeer(JFrame, boolean) so InlineStrategy can substitute a route-attach for the default Dialog-open path. Higher-level event firing (COMPONENT_SHOWN/HIDDEN, WINDOW_OPENED) stays in Window, same for both strategies.
      Overrides:
      applyVisibleToPeerImpl in class Window
    • disposePeer

      protected void disposePeer()
      Strategy hook for Window.dispose() — delegates peer tear-down through FrameStrategy.disposePeer(JFrame) so InlineStrategy can substitute a route-detach for the default SWindow.dispose path.
      Overrides:
      disposePeer in class Window
    • setTitle

      public void setTitle(String title)
      Overrides:
      setTitle in class Frame
    • isDefaultLookAndFeelDecorated

      public static boolean isDefaultLookAndFeelDecorated()
    • setJMenuBar

      public void setJMenuBar(JMenuBar bar)
      Delegates to the root pane, as the JDK's does (JFrame.java:470) — so frame.setJMenuBar(x) and frame.getRootPane().setJMenuBar(x) are the same bar, where they used to be two. The bar is planted in the root pane's layered pane, above the content pane.

      No "JMenuBar" bound property: the JDK routes setJMenuBar into JRootPane, and neither class fires anything for it. Firing one here handed migrated code a PropertyChangeEvent that never existed (R_decline_effect_only, D_window_fanout).

      JDK-shape signature uses javax.swing.JMenuBar; we accept JMenuBar per the import-swap migration arc (Stage 2 — user code rewrites import javax.swing.JMenuBar → import vaadinx.swing.JMenuBar).

    • getJMenuBar

      public JMenuBar getJMenuBar()
    • setIconImage

      public void setIconImage(Image arg0)
      Overrides:
      setIconImage in class Window
    • getGraphics

      public Graphics getGraphics()
      Overrides:
      getGraphics in class Component
    • repaint

      public void repaint(long arg0, int arg1, int arg2, int arg3, int arg4)
      Overrides:
      repaint in class Component
    • setDefaultCloseOperation

      public void setDefaultCloseOperation(int operation)
    • getDefaultCloseOperation

      public int getDefaultCloseOperation()
    • setTransferHandler

      public void setTransferHandler(TransferHandler newHandler)
    • getTransferHandler

      public TransferHandler getTransferHandler()
    • setDefaultLookAndFeelDecorated

      public static void setDefaultLookAndFeelDecorated(boolean arg0)
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()
      Specified by:
      getAccessibleContext in interface Accessible
      Overrides:
      getAccessibleContext in class Frame
    • dispatchShutdownFromTabClose

      public static void dispatchShutdownFromTabClose(com.vaadin.flow.server.VaadinSession session)
      Prompt-dispatch entry for the tab-scope destroy listener (AppTab.onTabClosed(VaadinSession, TabScope)): fires the D_shutdown_lifecycle WINDOW_CLOSING on a real app-tab close directly, rather than waiting for the VaadinSession-destroy backstop. Public only to cross the vaadinx → vaadinx.swing package seam; see the "Shutdown lifecycle (D_shutdown_lifecycle)" note above for why the reaper thread can't rely on the backstop.