Class Window

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
Dialog, Frame, JWindow

public class Window extends Container implements Accessible
Emulator for Window. Thin shell over SWindow.
See Also:
  • Constructor Details

  • Method Details

    • getLayout

      public LayoutManager getLayout()
      Overrides:
      getLayout in class Container
    • setLayout

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

      public boolean isOpaque()
      Overrides:
      isOpaque in class Component
    • isActive

      public boolean isActive()
    • getOwner

      public Window getOwner()
    • getLocale

      public Locale getLocale()
      Overrides:
      getLocale in class Component
    • setSize

      public void setSize(int width, int height)
      R_swing_is_truth mirror: store the Swing-side size, push to the SWindow peer's width/height channel, fire COMPONENT_RESIZED when the value actually changed. Non-SWindow peers (JFrame's InlineStrategy / SJPanel) skip the peer write — an inline main window keeps its viewport-fill stance per D_inline_route_sizing; the field shadow + event still happen so user code sees consistent Swing state.
      Overrides:
      setSize in class Component
    • setSize

      public void setSize(Dimension d)
      Overrides:
      setSize in class Component
    • dispose

      public void dispose()
    • disposePeer

      protected void disposePeer()
      Tear down the peer in response to dispose(). Default delegates to SWindow.dispose() when the peer is an SWindow (the standard SFrame / SJFrame / SDialog path). Subclasses with non-SWindow peers — notably JFrame's InlineStrategy with an SJPanel peer — override to detach from the route's div. Called under the preventPeerEvents guard so a peer-originated OpenedChangeEvent doesn't double-fire WINDOW_CLOSING.
    • getShape

      public Shape getShape()
    • getToolkit

      public Toolkit getToolkit()
      Overrides:
      getToolkit in class Component
    • setLocation

      public void setLocation(int x, int y)
      R_swing_is_truth mirror of setSize(int, int) for placement: store, push to the SWindow peer's top/left channel (which takes the Dialog overlay out of its default centered position), fire COMPONENT_MOVED on actual change. Same non-SWindow-peer skip as setSize.
      Overrides:
      setLocation in class Component
    • setLocation

      public void setLocation(Point p)
      Overrides:
      setLocation in class Component
    • setLocationByPlatform

      public void setLocationByPlatform(boolean b)
      Throws:
      IllegalComponentStateException - if b and the window is already showing, as AWT's own body does before it stores
    • isAlwaysOnTop

      public final boolean isAlwaysOnTop()
    • setAlwaysOnTop

      public final void setAlwaysOnTop(boolean b)
    • setIconImages

      public void setIconImages(List<? extends Image> icons)
    • addNotify

      public void addNotify()
      Overrides:
      addNotify in class Container
    • removeNotify

      public void removeNotify()
      Overrides:
      removeNotify in class Container
    • setMinimumSize

      public void setMinimumSize(Dimension arg0)
      Overrides:
      setMinimumSize in class Component
    • reshape

      public void reshape(int x, int y, int width, int height)
      Deprecated AWT 1.0 alias — in the JDK this is the actual worker setBounds delegates to; we invert the delegation so the modern name carries the implementation.
      Overrides:
      reshape in class Component
    • setBounds

      public void setBounds(int x, int y, int width, int height)
      Place + size in one call. Fires up to two component events (MOVED then RESIZED), matching AWT's reshape behaviour of reporting each aspect that changed.
      Overrides:
      setBounds in class Component
    • setBounds

      public void setBounds(Rectangle r)
      Overrides:
      setBounds in class Component
    • getLocation

      public Point getLocation()
      Overrides:
      getLocation in class Component
    • getLocation

      public Point getLocation(Point rv)
      Overrides:
      getLocation in class Component
    • getSize

      public Dimension getSize()
      Overrides:
      getSize in class Component
    • getSize

      public Dimension getSize(Dimension rv)
      Overrides:
      getSize in class Component
    • getBounds

      public Rectangle getBounds()
      Overrides:
      getBounds in class Component
    • getBounds

      public Rectangle getBounds(Rectangle rv)
      Overrides:
      getBounds in class Component
    • getX

      public int getX()
      Overrides:
      getX in class Component
    • getY

      public int getY()
      Overrides:
      getY in class Component
    • getWidth

      public int getWidth()
      Overrides:
      getWidth in class Component
    • getHeight

      public int getHeight()
      Overrides:
      getHeight in class Component
    • setVisible

      public void setVisible(boolean b)
      Overrides:
      setVisible in class Component
    • show

      public void show()
      Overrides:
      show in class Component
    • hide

      public void hide()
      Overrides:
      hide in class Component
    • applyVisibleToPeer

      protected final void applyVisibleToPeer(boolean b)
      Apply visibility to the peer in response to setVisible(boolean). Default delegates to SWindow.setVisible(boolean) when the peer is an SWindow (standard Dialog-backed shape); falls through to Component.setVisible(boolean) for non-SWindow peers as defensive coverage. Subclasses with bespoke peer-attach semantics — notably JFrame's InlineStrategy with an SJPanel peer attached to a route's div — override to substitute their own peer manipulation. Called under the preventPeerEvents guard so a peer-originated OpenedChangeEvent doesn't double-fire.
      Overrides:
      applyVisibleToPeer in class Component
    • blocksAfterVisibilityChange

      protected boolean blocksAfterVisibilityChange(boolean b)
      Whether the caller will block on a browser round-trip once this visibility change has been applied — true only for a modal Dialog.show(), which parks until the user answers. Decided on our side rather than the migrator's, which is what makes it answerable at all; the set is small and closed.
      Parameters:
      b - the visibility being applied, since only a show can be followed by a park
    • applyVisibleToPeerImpl

      protected void applyVisibleToPeerImpl(boolean b)
      The peer write itself, already on the UI thread and inside the preventPeerEvents guard. Subclasses with bespoke peer-attach semantics — notably JFrame's InlineStrategy with an SJPanel peer attached to a route's div — override this rather than applyVisibleToPeer(boolean), so the hop and the guard cannot be bypassed by forgetting to call super.
    • toFront

      public void toFront()
    • postEvent

      @Deprecated public boolean postEvent(Event arg0)
      Deprecated.
      Specified by:
      postEvent in interface MenuContainer
      Overrides:
      postEvent in class Component
    • toBack

      public void toBack()
    • setCursor

      public void setCursor(Cursor arg0)
      Overrides:
      setCursor in class Component
    • getWindows

      public static Window[] getWindows()
    • getOwnedWindows

      public Window[] getOwnedWindows()
    • processWindowEvent

      protected void processWindowEvent(WindowEvent e)
    • processWindowFocusEvent

      protected void processWindowFocusEvent(WindowEvent e)
    • processWindowStateEvent

      protected void processWindowStateEvent(WindowEvent e)
    • processEvent

      protected void processEvent(AWTEvent e)
      Overrides:
      processEvent in class Container
    • fireWindowEvent

      protected void fireWindowEvent(int id)
    • fireWindowFocusEvent

      protected void fireWindowFocusEvent(int id, Window opposite)
    • fireWindowStateEvent

      protected void fireWindowStateEvent(int oldState, int newState)
    • isAlwaysOnTopSupported

      public boolean isAlwaysOnTopSupported()
    • isFocused

      public boolean isFocused()
    • getFocusOwner

      public Component getFocusOwner()
    • getMostRecentFocusOwner

      public Component getMostRecentFocusOwner()
    • isFocusableWindow

      public final boolean isFocusableWindow()
    • getFocusableWindowState

      public boolean getFocusableWindowState()
    • setFocusableWindowState

      public void setFocusableWindowState(boolean focusableWindowState)
    • addPropertyChangeListener

      public void addPropertyChangeListener(String arg0, PropertyChangeListener arg1)
      Overrides:
      addPropertyChangeListener in class Container
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener arg0)
      Overrides:
      addPropertyChangeListener in class Container
    • applyResourceBundle

      public void applyResourceBundle(ResourceBundle arg0)
    • applyResourceBundle

      public void applyResourceBundle(String arg0)
    • addWindowListener

      public void addWindowListener(WindowListener l)
    • addWindowFocusListener

      public void addWindowFocusListener(WindowFocusListener l)
    • addWindowStateListener

      public void addWindowStateListener(WindowStateListener l)
    • createBufferStrategy

      public void createBufferStrategy(int arg0, BufferCapabilities arg1) throws AWTException
      Throws:
      AWTException
    • createBufferStrategy

      public void createBufferStrategy(int arg0)
    • getBufferStrategy

      public BufferStrategy getBufferStrategy()
    • setOpacity

      public void setOpacity(float arg0)
      AWT's other two throws are not reproduced, and deliberately: both ask the platform whether it can do translucency at all — a browser can, so the answers would be "yes, supported" and the throws unreachable. What is declined is the peer push, so the window renders fully opaque.
      Parameters:
      arg0 - in [0, 1]
      Throws:
      IllegalArgumentException - outside that range, as AWT does
    • getBackground

      public Color getBackground()
      Overrides:
      getBackground in class Component
    • setBackground

      public void setBackground(Color arg0)
      Overrides:
      setBackground in class Component
    • paint

      public void paint(Graphics arg0)
      Overrides:
      paint in class Container
    • getIconImages

      public List<Image> getIconImages()
    • setIconImage

      public void setIconImage(Image image)
    • pack

      public void pack()
    • getWarningString

      public final String getWarningString()
    • getInputContext

      public InputContext getInputContext()
      Overrides:
      getInputContext in class Component
    • getOwnerlessWindows

      public static Window[] getOwnerlessWindows()
    • removeWindowListener

      public void removeWindowListener(WindowListener l)
    • removeWindowStateListener

      public void removeWindowStateListener(WindowStateListener l)
    • removeWindowFocusListener

      public void removeWindowFocusListener(WindowFocusListener l)
    • getWindowListeners

      public WindowListener[] getWindowListeners()
    • getWindowFocusListeners

      public WindowFocusListener[] getWindowFocusListeners()
    • getWindowStateListeners

      public WindowStateListener[] getWindowStateListeners()
    • getFocusTraversalKeys

      public Set<AWTKeyStroke> getFocusTraversalKeys(int arg0)
      Overrides:
      getFocusTraversalKeys in class Container
    • setFocusCycleRoot

      public final void setFocusCycleRoot(boolean b)
      Overrides:
      setFocusCycleRoot in class Container
    • isFocusCycleRoot

      public final boolean isFocusCycleRoot()
      Overrides:
      isFocusCycleRoot in class Container
    • getFocusCycleRootAncestor

      public final Container getFocusCycleRootAncestor()
      Overrides:
      getFocusCycleRootAncestor in class Component
    • setAutoRequestFocus

      public void setAutoRequestFocus(boolean b)
    • isAutoRequestFocus

      public boolean isAutoRequestFocus()
    • isValidateRoot

      public boolean isValidateRoot()
      Overrides:
      isValidateRoot in class Container
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()
      Specified by:
      getAccessibleContext in interface Accessible
      Overrides:
      getAccessibleContext in class Component
    • setLocationRelativeTo

      public void setLocationRelativeTo(Component c)
      AWT: null centers on screen, a visible component centers over that component. Both map to viewport-centering here — see SWindow.setLocationRelativeTo(Component) for the R_layouts_close_enough close-enough rationale. Clears the explicit-location shadow (the window is centered again, not at the last set coordinates); fires COMPONENT_MOVED only if an explicit placement was in effect, since a still-centered window didn't move.
    • isLocationByPlatform

      public boolean isLocationByPlatform()
    • getOpacity

      public float getOpacity()
    • setShape

      public void setShape(Shape arg0)