# Class Window

java.lang.Object
com.codename1.ui.Component
com.codename1.ui.Container
com.codename1.ui.Window

All Implemented Interfaces:
  `Animation, Editable, StyleListener, TopLevelContainer, Iterable<Component>`

public class Window extends Container implements TopLevelContainer

A separate native operating system window, with its own Codename One component hierarchy inside it.

A `Window` is the desktop counterpart of `Form`. The application's main surface stays a `Form` and keeps behaving exactly as it always has; a `Window` is an additional top level, rendered into its own native window, with its own focus owner, its own animations and its own dirty region.

    if (Desktop.isSupported()) {
        Window w = new Window("Inspector", new BorderLayout());
        w.add(BorderLayout.CENTER, new Label("Hello from a second window"));
        w.setWindowSize(400, 300);
        w.show();
    }

A `Window` is not a `Form`, so `Component#getComponentForm()` returns null for the components inside one. Code that has to work in both places should ask for `Component#getTopLevelContainer()` instead.

Windows exist only where the platform has a windowing system. Every constructor throws `UnsupportedOperationException` when it does not, so guard with `Desktop#isSupported()`. There is deliberately no silent fallback to showing a `Form`: a window that quietly is not a window produces layout and lifecycle bugs that are far harder to find than an exception on the first line.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `DISPOSE_ON_CLOSE`
  Closing the window disposes it and releases the native window.
  `static final int`
  `DO_NOTHING_ON_CLOSE`
  Closing the window does nothing, leaving the application to call `#dispose()` itself from a close listener.
  `static final int`
  `HIDE_ON_CLOSE`
  Closing the window hides it, leaving it able to be shown again.
  `static final int`
  `MODALITY_APPLICATION`
  The window blocks input to every other window and to the main form.
  `static final int`
  `MODALITY_NONE`
  The window does not block input to any other window.
  `static final int`
  `MODALITY_WINDOW`
  The window blocks input to the window that owns it.

  ### Fields inherited from class Component

  `BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Window()`
  Creates a window whose content is laid out with a `FlowLayout`.
  `Window(Layout contentPaneLayout)`
  Creates a window with the given content layout.
  `Window(String title)`
  Creates a window with the given title, laid out with a `FlowLayout`.
  `Window(String title, Layout contentPaneLayout)`
  Creates a window with the given title and content layout.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addCloseListener(ActionListener l)`
  Adds a listener notified when the user tries to close this window.
  `void`
  `addCommand(Command cmd)`
  Adds a command to this top level.
  `void`
  `addCommandListener(ActionListener l)`
  Adds a listener notified when a command is activated.
  `void`
  `addComponent(int index, Component cmp)`
  This method adds the Component at a specific index location in the Container Components array.
  `void`
  `addComponent(int index, Object constraints, Component cmp)`
  Adds a Component to the Container
  `void`
  `addComponent(Component cmp)`
  Adds a Component to the Container
  `void`
  `addComponent(Object constraints, Component cmp)`
  Adds a Component to the Container
  `<C extends Component>
  void`
  `addComponentAwaitingRelease(C c)`
  Returns this top level as a `Container`.
  `void`
  `addKeyListener(int keyCode, ActionListener listener)`
  Adds a key binding scoped to this top level.
  `void`
  `addShowListener(ActionListener l)`
  Adds a listener notified whenever this top level is shown.
  `void`
  `addSizeChangedListener(ActionListener l)`
  Adds a listener notified whenever this top level changes size.
  `void`
  `addWindowListener(ActionListener l)`
  Adds a listener notified when this window is shown, hidden, moved or resized.
  `void`
  `animateHierarchy(int duration)`
  Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation
  `void`
  `animateHierarchyAndWait(int duration)`
  Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation.
  `void`
  `animateHierarchyFade(int duration, int startingOpacity)`
  Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation
  `void`
  `animateHierarchyFadeAndWait(int duration, int startingOpacity)`
  Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation.
  `void`
  `animateLayout(int duration)`
  Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation
  `void`
  `animateLayoutAndWait(int duration)`
  Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation.
  `void`
  `animateLayoutFade(int duration, int startingOpacity)`
  Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation
  `void`
  `animateLayoutFadeAndWait(int duration, int startingOpacity)`
  Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation.
  `void`
  `animateUnlayout(int duration, int opacity, Runnable callback)`
  This method is the exact reverse of animateLayout, when completed it leaves the container in an invalid state.
  `void`
  `animateUnlayoutAndWait(int duration, int opacity)`
  This method is the exact reverse of animateLayoutAndWait, when completed it leaves the container in an invalid state.
  `Container`
  `asContainer()`
  `Image`
  `capture()`
  Captures this window's current contents.
  `void`
  `centerOn(TopLevelContainer other)`
  Centres this window over another top level.
  `void`
  `centerOnDesktop()`
  Centres this window on the work area of the monitor it sits on, so it does not land under the task bar or dock.
  `void`
  `clearComponentsAwaitingRelease()`
  Drops every component waiting for a pointer release, used when a gesture is taken over by something else -- a pull to refresh, for instance.
  `void`
  `deregisterAnimated(Animation cmp)`
  Removes a previously registered animation.
  `void`
  `dispatchCommand(Command cmd, ActionEvent ev)`
  Dispatches a command to this top level's command handling, which is how a component that holds a `Command` triggers it without knowing whether it lives in a `Form` or a `Window`.
  `void`
  `dispose()`
  Destroys this window and releases the native window behind it.
  `Component`
  `findCurrentlyEditingComponent()`
  Returns the component currently being edited.
  `AnimationManager`
  `getAnimationManager()`
  Returns the animation manager coordinating mutations of this top level.
  `int`
  `getCloseOperation()`
  Returns what happens when the user closes this window.
  `Command`
  `getCommand(int index)`
  Returns the command at the given offset.
  `int`
  `getCommandCount()`
  Returns the number of commands.
  `int`
  `getComponentIndex(Component cmp)`
  Returns the Component index in the Container
  `Container`
  `getContentPane()`
  Returns the container holding the application content of this top level.
  `VirtualInputDevice`
  `getCurrentInputDevice()`
  Returns the virtual input device currently open for this top level.
  `int`
  `getDensity()`
  Returns the density of the monitor this window sits on, which on a mixed resolution desktop is not necessarily the density `Display` reports.
  `int`
  `getDragRegionStatus(int x, int y)`
  Indicates if the section within the X/Y area is a "drag region" where we expect people to drag or press in which case we can instantly start dragging making perceived performance faster.
  `Component`
  `getFocused()`
  Returns the component currently owning focus.
  `Container`
  `getFormLayeredPane(Class c, boolean top)`
  Returns the layer belonging to the given class within the layered pane that spans the whole top level, including the title area, creating it if needed.
  `Painter`
  `getGlassPane()`
  Returns the painter drawn above everything else in this top level.
  `int`
  `getInvisibleAreaUnderVKB()`
  Returns the height hidden behind the virtual keyboard, which is zero on a platform without one.
  `Container`
  `getLayeredPane()`
  Returns the layered pane covering the content area, creating it if needed.
  `Container`
  `getLayeredPane(Class c, boolean top)`
  Returns the layer belonging to the given class within the content-area layered pane, creating it if needed.
  `Container`
  `getLayeredPane(Class c, int zIndex)`
  Returns the layer belonging to the given class within the content-area layered pane at an explicit depth, creating it if needed.
  `Layout`
  `getLayout()`
  Returns the layout manager responsible for arranging this container.
  `Dimension`
  `getMinimumWindowSize()`
  Returns the smallest size the user may resize this window to.
  `int`
  `getModalityType()`
  Returns how this window blocks input to the others.
  `Monitor`
  `getMonitor()`
  Returns the monitor this window currently sits on.
  `TopLevelContainer`
  `getOwnerWindow()`
  Returns the top level that owns this window.
  `Rectangle`
  `getSafeArea()`
  Returns the region of this top level that is guaranteed not to be obscured by system chrome such as a notch or a rounded corner.
  `double`
  `getScale()`
  Returns the backing scale of the monitor this window sits on.
  `int`
  `getScrollAnimationSpeed()`
  Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode
  `int`
  `getSideGap()`
  Returns the gap to be left for the side scrollbar on the Y axis.
  `Form.TabIterator`
  `getTabIterator(Component start)`
  Returns an iterator walking the components in traversal order.
  `TextSelection`
  `getTextSelection()`
  Returns the text selection support for this top level.
  `String`
  `getTitle()`
  Returns the title text.
  `TopLevelContainer`
  `getTopLevelContainer()`
  Returns the top level container this component currently belongs to, which is either the `Form` filling the main surface or the `Window` of a native desktop window, or null when this component is not attached to one.
  `UIManager`
  `getUIManager()`
  This method should be used by the Component to retrieve the correct UIManager to work with
  `Rectangle`
  `getWindowBounds()`
  Returns this window's bounds in desktop coordinates, including any native chrome.
  `Image`
  `getWindowIcon()`
  Returns the icon the platform shows for this window.
  `int`
  `getWindowId()`
  Returns the framework assigned id of this window.
  `boolean`
  `grabAnimationLock()`
  Takes the animation lock, blocking until no animation is in progress.
  `boolean`
  `hasPaintedOnce()`
  Indicates whether this window has completed at least one paint cycle, and so whether its content -- rather than an empty surface -- is what a capture would return.
  `void`
  `hide()`
  Hides this window without destroying it, so it can be shown again.
  `boolean`
  `isAlwaysOnTop()`
  Indicates whether this window floats above the others.
  `boolean`
  `isAlwaysTensile()`
  Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)
  `boolean`
  `isCyclicFocus()`
  Returns true when focus traversal wraps around at the edges.
  `boolean`
  `isDecorated()`
  Indicates whether the platform draws this window's chrome.
  `boolean`
  `isEditing()`
  Checks if the component is currently being edited.
  `boolean`
  `isEnableCursors()`
  Returns true when components may change the mouse cursor.
  `boolean`
  `isResizable()`
  Indicates whether the user may resize this window.
  `boolean`
  `isScrollable()`
  Indicates whether the component should/could scroll by default a component is not scrollable.
  `boolean`
  `isScrollableX()`
  Indicates whether the component should/could scroll on the X axis
  `boolean`
  `isScrollableY()`
  Indicates whether the component should/could scroll on the Y axis
  `boolean`
  `isScrollVisible()`
  Indicate whether this component scroll is visible
  `boolean`
  `isSingleFocusMode()`
  Returns true when only one component in this top level can take focus.
  `boolean`
  `isSmoothScrolling()`
  Indicates that scrolling through the component should work as an animation
  `boolean`
  `isUtilityWindow()`
  Indicates whether this is a utility window.
  `boolean`
  `isWindowDisposed()`
  Indicates whether this window has been disposed.
  `boolean`
  `isWindowFocused()`
  Indicates whether this window currently holds keyboard focus.
  `boolean`
  `isWindowShowing()`
  Indicates whether this window is currently mapped on screen.
  `void`
  `keyPressed(int keyCode)`
  If this Component is focused, the key pressed event will call this method
  `void`
  `keyReleased(int keyCode)`
  If this Component is focused, the key released event will call this method
  `void`
  `keyRepeated(int keyCode)`
  If this Component is focused, the key repeat event will call this method.
  `protected void`
  `longKeyPress(int keyCode)`
  If this Component is focused this method is invoked when the user presses and holds the key
  `void`
  `longPointerPress(int x, int y)`
  If this Component is focused this method is invoked when the user presses and holds the pointer on the Component
  `void`
  `minimize()`
  Minimizes this window.
  `void`
  `paint(Graphics g)`
  This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.
  `void`
  `pointerDragged(int[] x, int[] y)`
  If this Component is focused, the pointer dragged event will call this method
  `void`
  `pointerDragged(int x, int y)`
  If this Component is focused, the pointer dragged event will call this method
  `void`
  `pointerHover(int[] x, int[] y)`
  Invoked for devices where the pointer can hover without actually clicking the display.
  `void`
  `pointerHoverPressed(int[] x, int[] y)`
  Invoked for devices where the pointer can hover without actually clicking the display.
  `void`
  `pointerHoverReleased(int[] x, int[] y)`
  Invoked for devices where the pointer can hover without actually clicking the display.
  `void`
  `pointerPressed(int x, int y)`
  If this Component is focused, the pointer pressed event will call this method
  `void`
  `pointerReleased(int x, int y)`
  If this Component is focused, the pointer released event will call this method
  `void`
  `registerAnimated(Animation cmp)`
  Registers an animation that is invoked on every frame of this top level.
  `void`
  `releaseAnimationLock()`
  Releases a previously taken animation lock.
  `void`
  `removeAll()`
  remove all Components from container, notice that removed component might still have a pending repaint in the queue that won't be removed.
  `void`
  `removeAllCommands()`
  Removes every command from this top level.
  `void`
  `removeCloseListener(ActionListener l)`
  Removes a previously added close listener.
  `void`
  `removeCommand(Command cmd)`
  Removes a command from this top level.
  `void`
  `removeCommandListener(ActionListener l)`
  Removes a previously added command listener.
  `void`
  `removeComponent(Component cmp)`
  removes a Component from the Container, notice that removed component might still have a pending repaint in the queue that won't be removed.
  `<C extends Component>
  void`
  `removeComponentAwaitingRelease(C c)`
  Stops tracking a component that was waiting for a pointer release.
  `void`
  `removeKeyListener(int keyCode, ActionListener listener)`
  Removes a previously added key binding.
  `void`
  `removeShowListener(ActionListener l)`
  Removes a previously added show listener.
  `void`
  `removeSizeChangedListener(ActionListener l)`
  Removes a previously added size changed listener.
  `void`
  `removeWindowListener(ActionListener l)`
  Removes a previously added window listener.
  `void`
  `replace(Component current, Component next, Transition t)`
  This method replaces the current Component with the next Component.
  `void`
  `replaceAndWait(Component current, Component next, Transition t)`
  This method replaces the current Component with the next Component.
  `void`
  `requestWindowFocus()`
  Raises this window and gives it keyboard focus.
  `void`
  `restore()`
  Restores this window from a minimized state.
  `void`
  `scrollComponentToVisible(Component c)`
  Makes sure the component is visible in the scroll if this container is scrollable
  `void`
  `setAlwaysOnTop(boolean alwaysOnTop)`
  Keeps this window above the application's other windows.
  `void`
  `setAlwaysTensile(boolean alwaysTensile)`
  Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)
  `void`
  `setCloseOperation(int op)`
  Sets what happens when the user closes this window through the platform's own close control.
  `void`
  `setCurrentInputDevice(VirtualInputDevice device)`
  Opens a virtual input device, closing whichever one was open before it.
  `void`
  `setCyclicFocus(boolean cyclicFocus)`
  Sets whether focus traversal wraps around at the edges.
  `void`
  `setDecorated(boolean decorated)`
  Sets whether the platform draws a title bar and border for this window.
  `void`
  `setEnableCursors(boolean e)`
  Sets whether components may change the mouse cursor.
  `void`
  `setFocused(Component focused)`
  Moves focus to the given component.
  `void`
  `setGlassPane(Painter glassPane)`
  Sets the painter drawn above everything else in this top level.
  `void`
  `setLayout(Layout layout)`
  Sets the layout manager responsible for arranging this container
  `void`
  `setMinimumWindowSize(Dimension d)`
  Sets the smallest size the user may resize this window to.
  `void`
  `setModalityType(int type)`
  Sets how this window blocks input to the others.
  `void`
  `setOwnerWindow(TopLevelContainer owner)`
  Sets the top level that owns this window.
  `void`
  `setResizable(boolean resizable)`
  Sets whether the user may resize this window.
  `void`
  `setRTL(boolean r)`
  Is the component a bidi RTL component
  `void`
  `setScrollable(boolean scrollable)`
  The equivalent of calling both setScrollableY and setScrollableX
  `void`
  `setScrollableX(boolean scrollableX)`
  Sets whether the component should/could scroll on the X axis
  `void`
  `setScrollableY(boolean scrollableY)`
  Sets whether the component should/could scroll on the Y axis
  `void`
  `setScrollAnimationSpeed(int animationSpeed)`
  Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode
  `void`
  `setScrollVisible(boolean scrollVisible)`
  Set whether this component scroll is visible
  `void`
  `setSmoothScrolling(boolean smoothScrolling)`
  Indicates that scrolling through the component should work as an animation
  `void`
  `setTitle(String title)`
  Sets the title text.
  `void`
  `setUIManager(UIManager uiManager)`
  Allows replacing the UIManager in a component hierarchy to update the look and feel only to a specific hierarchy
  `void`
  `setUtilityWindow(boolean utility)`
  Marks this window as a palette or tool window, which the platform typically keeps out of the task bar.
  `void`
  `setWindowBounds(Rectangle r)`
  Moves and resizes this window.
  `void`
  `setWindowIcon(Image icon)`
  Sets the icon the platform shows for this window.
  `void`
  `setWindowLocation(int x, int y)`
  Moves this window, leaving its size alone.
  `void`
  `setWindowSize(int width, int height)`
  Resizes this window, leaving its position alone.
  `void`
  `show()`
  Shows this window, creating the native window the first time it is called.
  `void`
  `showModal()`
  Shows this window and blocks the calling code until it stops being on screen -- whether that is `#dispose()` or `#hide()`.
  `void`
  `stopEditing(Runnable onFinish)`
  Stops the editing process.
  `void`
  `toggleMaximize()`
  Toggles this window between maximized and its previous size.

  ### Methods inherited from class Container

  `add, add, add, add, add, add, addAll, applyRTL, calcPreferredSize, cancelRepaints, clearClientProperties, constrainHeightWhenScrollable, constrainWidthWhenScrollable, contains, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayout, createAnimateLayoutFade, createAnimateLayoutFadeAndWait, createAnimateMotion, createAnimateUnlayout, createReplaceTransition, dragInitiated, drop, encloseIn, encloseIn, findDropTargetAt, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getChildrenAsList, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getGridPosX, getGridPosY, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getResponderAt, getSafeAreaRoot, getScrollIncrement, initLaf, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isSelectableInteraction, isSurface, iterator, iterator, layoutContainer, morph, morphAndWait, paintComponentBackground, paintGlass, paramString, refreshTheme, replace, replaceAndWait, replaceAndWait, revalidate, revalidateLater, revalidateWithAnimationSafety, setCellRenderer, setEnabled, setLeadComponent, setSafeArea, setSafeAreaRoot, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, updateTabIndices`

  ### Methods inherited from class Component

  `accessibilityChanged, accessibilityChanged, addContextMenuListener, addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addMouseWheelListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, addStylusListener, animate, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, consumesRawTextInput, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, deregisterFromAnimation, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAccessibilityNode, getAccessibilityText, getAllStyles, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragSpeed, getDragTransparency, getEditingDelegate, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSemantics, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isHScrollThumbGrabbed, isHScrollThumbHover, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isSetCursorSupported, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, isVScrollThumbGrabbed, isVScrollThumbHover, laidOut, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, registerForAnimation, remove, removeContextMenuListener, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removeMouseWheelListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, removeStylusListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, rotation, scrollRectToVisible, scrollRectToVisible, setAccessibilityText, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setHorizontalScrollBounds, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setPropertyValue, setPullToRefresh, setRippleEffect, setSameHeight, setSameSize, setSameWidth, setScrollOpacityChangeSpeed, setScrollSize, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUIIDFinal, setUnselectedStyle, setVerticalScrollBounds, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContains`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface Iterable

  `forEach`

- ## Field Details

  - ### DISPOSE_ON_CLOSE

    public static final int DISPOSE_ON_CLOSE
    Closing the window disposes it and releases the native window. The default.
    See Also:
      - Constant Field Values

  - ### HIDE_ON_CLOSE

    public static final int HIDE_ON_CLOSE
    Closing the window hides it, leaving it able to be shown again.
    See Also:
      - Constant Field Values

  - ### DO_NOTHING_ON_CLOSE

    public static final int DO_NOTHING_ON_CLOSE
    Closing the window does nothing, leaving the application to call `#dispose()` itself from a close listener.
    See Also:
      - Constant Field Values

  - ### MODALITY_NONE

    public static final int MODALITY_NONE
    The window does not block input to any other window.
    See Also:
      - Constant Field Values

  - ### MODALITY_WINDOW

    public static final int MODALITY_WINDOW
    The window blocks input to the window that owns it.
    See Also:
      - Constant Field Values

  - ### MODALITY_APPLICATION

    public static final int MODALITY_APPLICATION
    The window blocks input to every other window and to the main form.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### Window

    public Window()
    Creates a window whose content is laid out with a `FlowLayout`.

  - ### Window

    public Window(Layout contentPaneLayout)

    Creates a window with the given content layout.

    ###### Parameters

    - `contentPaneLayout`: the layout for the content pane

  - ### Window

    public Window(String title)

    Creates a window with the given title, laid out with a `FlowLayout`.

    ###### Parameters

    - `title`: the window title

  - ### Window

    public Window(String title, Layout contentPaneLayout)

    Creates a window with the given title and content layout.

    ###### Parameters

    - `title`: the window title

    - `contentPaneLayout`: the layout for the content pane

- ## Method Details

  - ### getWindowId

    public int getWindowId()

    Returns the framework assigned id of this window.

    This is the id a port stores at creation and echoes back on every event, so it is also how a window is looked up from `Desktop#windowById(int)`.

    ###### Returns

    the window id

  - ### asContainer

    public Container asContainer()
    Specified by:
      `asContainer` in interface `TopLevelContainer`

  - ### getTopLevelContainer

    public TopLevelContainer getTopLevelContainer()

    Returns the top level container this component currently belongs to, which is either the `Form` filling the main surface or the `Window` of a native desktop window, or null when this component is not attached to one.

    Prefer this over `#getComponentForm()` in code that must keep working inside a desktop `Window`. `getComponentForm()` keeps its original meaning and returns null for a component hosted in a `Window`, because a `Window` is not a `Form`.

    ###### Returns

    the enclosing top level container, or null when detached

    ###### See also

    - #getComponentForm()
    Overrides:
      `getTopLevelContainer` in class `Component`

  - ### getContentPane

    public Container getContentPane()

    Returns the container holding the application content of this top level.

    ###### Returns

    the content pane

    Specified by:
      `getContentPane` in interface `TopLevelContainer`

  - ### getLayeredPane

    public Container getLayeredPane()

    Returns the layered pane covering the content area, creating it if needed.

    ###### Returns

    the layered pane

    Specified by:
      `getLayeredPane` in interface `TopLevelContainer`

  - ### getLayeredPane

    public Container getLayeredPane(Class c, boolean top)

    Returns the layer belonging to the given class within the content-area layered pane, creating it if needed.

    ###### Parameters

    - `c`: the class owning the layer

    - `top`: true to place the layer above the existing layers

    ###### Returns

    the layer for the given class

    Specified by:
      `getLayeredPane` in interface `TopLevelContainer`

  - ### getLayeredPane

    public Container getLayeredPane(Class c, int zIndex)

    Returns the layer belonging to the given class within the content-area layered pane at an explicit depth, creating it if needed.

    ###### Parameters

    - `c`: the class owning the layer

    - `zIndex`: the depth at which the layer should sit

    ###### Returns

    the layer for the given class

    Specified by:
      `getLayeredPane` in interface `TopLevelContainer`

  - ### getFormLayeredPane

    public Container getFormLayeredPane(Class c, boolean top)

    Returns the layer belonging to the given class within the layered pane that spans the whole top level, including the title area, creating it if needed.

    ###### Parameters

    - `c`: the class owning the layer

    - `top`: true to place the layer above the existing layers

    ###### Returns

    the layer for the given class

    The name mirrors `Form#getFormLayeredPane(java.lang.Class, boolean)` on purpose: `Sheet`, `InteractionDialog` and `ToastBar` attach through this method, and renaming it for windows would fork them.

    Specified by:
      `getFormLayeredPane` in interface `TopLevelContainer`

  - ### getGlassPane

    public Painter getGlassPane()

    Returns the painter drawn above everything else in this top level.

    ###### Returns

    the glass pane painter, or null when none is installed

    Specified by:
      `getGlassPane` in interface `TopLevelContainer`

  - ### setGlassPane

    public void setGlassPane(Painter glassPane)

    Sets the painter drawn above everything else in this top level.

    ###### Parameters

    - `glassPane`: the painter to install, or null to remove the current one
    Specified by:
      `setGlassPane` in interface `TopLevelContainer`

  - ### getTitle

    public String getTitle()

    Returns the title text.

    ###### Returns

    the title

    Specified by:
      `getTitle` in interface `TopLevelContainer`

  - ### setTitle

    public void setTitle(String title)
    Description copied from interface: `TopLevelContainer`

    Sets the title text.

    ###### Parameters

    - `title`: the title to display
    Specified by:
      `setTitle` in interface `TopLevelContainer`

  - ### addCommand

    public void addCommand(Command cmd)

    Adds a command to this top level.

    ###### Parameters

    - `cmd`: the command to add
    Specified by:
      `addCommand` in interface `TopLevelContainer`

  - ### removeCommand

    public void removeCommand(Command cmd)

    Removes a command from this top level.

    ###### Parameters

    - `cmd`: the command to remove
    Specified by:
      `removeCommand` in interface `TopLevelContainer`

  - ### removeAllCommands

    public void removeAllCommands()
    Removes every command from this top level.
    Specified by:
      `removeAllCommands` in interface `TopLevelContainer`

  - ### getCommandCount

    public int getCommandCount()

    Returns the number of commands.

    ###### Returns

    the command count

    Specified by:
      `getCommandCount` in interface `TopLevelContainer`

  - ### getCommand

    public Command getCommand(int index)

    Returns the command at the given offset.

    ###### Parameters

    - `index`: the offset of the command

    ###### Returns

    the command at that offset

    Specified by:
      `getCommand` in interface `TopLevelContainer`

  - ### addCommandListener

    public void addCommandListener(ActionListener l)

    Adds a listener notified when a command is activated.

    ###### Parameters

    - `l`: the listener to add
    Specified by:
      `addCommandListener` in interface `TopLevelContainer`

  - ### removeCommandListener

    public void removeCommandListener(ActionListener l)

    Removes a previously added command listener.

    ###### Parameters

    - `l`: the listener to remove
    Specified by:
      `removeCommandListener` in interface `TopLevelContainer`

  - ### dispatchCommand

    public void dispatchCommand(Command cmd, ActionEvent ev)
    Description copied from interface: `TopLevelContainer`

    Dispatches a command to this top level's command handling, which is how a component that holds a `Command` triggers it without knowing whether it lives in a `Form` or a `Window`.

    ###### Parameters

    - `cmd`: the command to dispatch

    - `ev`: the event to dispatch

    Specified by:
      `dispatchCommand` in interface `TopLevelContainer`

  - ### getAnimationManager

    public AnimationManager getAnimationManager()

    Returns the animation manager coordinating mutations of this top level.

    ###### Returns

    the animation manager

    Specified by:
      `getAnimationManager` in interface `TopLevelContainer`
    Overrides:
      `getAnimationManager` in class `Component`

  - ### registerAnimated

    public void registerAnimated(Animation cmp)

    Registers an animation that is invoked on every frame of this top level.

    ###### Parameters

    - `cmp`: the animation to register
    Specified by:
      `registerAnimated` in interface `TopLevelContainer`

  - ### deregisterAnimated

    public void deregisterAnimated(Animation cmp)

    Removes a previously registered animation.

    ###### Parameters

    - `cmp`: the animation to remove
    Specified by:
      `deregisterAnimated` in interface `TopLevelContainer`

  - ### grabAnimationLock

    public boolean grabAnimationLock()

    Takes the animation lock, blocking until no animation is in progress.

    ###### Returns

    true if the lock was taken

    Specified by:
      `grabAnimationLock` in interface `TopLevelContainer`

  - ### releaseAnimationLock

    public void releaseAnimationLock()
    Releases a previously taken animation lock.
    Specified by:
      `releaseAnimationLock` in interface `TopLevelContainer`

  - ### getFocused

    public Component getFocused()

    Returns the component currently owning focus.

    ###### Returns

    the focus owner, or null when nothing is focused

    Specified by:
      `getFocused` in interface `TopLevelContainer`

  - ### setFocused

    public void setFocused(Component focused)

    Moves focus to the given component.

    ###### Parameters

    - `focused`: the component that should take focus
    Specified by:
      `setFocused` in interface `TopLevelContainer`

  - ### isCyclicFocus

    public boolean isCyclicFocus()

    Returns true when focus traversal wraps around at the edges.

    ###### Returns

    true if focus is cyclic

    Specified by:
      `isCyclicFocus` in interface `TopLevelContainer`

  - ### setCyclicFocus

    public void setCyclicFocus(boolean cyclicFocus)

    Sets whether focus traversal wraps around at the edges.

    ###### Parameters

    - `cyclicFocus`: true to make focus cyclic
    Specified by:
      `setCyclicFocus` in interface `TopLevelContainer`

  - ### isSingleFocusMode

    public boolean isSingleFocusMode()

    Returns true when only one component in this top level can take focus.

    ###### Returns

    true if this is a single focus top level

    Specified by:
      `isSingleFocusMode` in interface `TopLevelContainer`

  - ### getTabIterator

    public Form.TabIterator getTabIterator(Component start)

    Returns an iterator walking the components in traversal order.

    ###### Parameters

    - `start`: the component to start from

    ###### Returns

    the traversal iterator

    Specified by:
      `getTabIterator` in interface `TopLevelContainer`

  - ### scrollComponentToVisible

    public void scrollComponentToVisible(Component c)

    Makes sure the component is visible in the scroll if this container is scrollable

    ###### Parameters

    - `c`: the component that will be scrolling for visibility
    Specified by:
      `scrollComponentToVisible` in interface `TopLevelContainer`
    Overrides:
      `scrollComponentToVisible` in class `Container`

  - ### addKeyListener

    public void addKeyListener(int keyCode, ActionListener listener)

    Adds a key binding scoped to this top level.

    ###### Parameters

    - `keyCode`: the key code to bind

    - `listener`: the listener invoked for that key

    Specified by:
      `addKeyListener` in interface `TopLevelContainer`

  - ### removeKeyListener

    public void removeKeyListener(int keyCode, ActionListener listener)

    Removes a previously added key binding.

    ###### Parameters

    - `keyCode`: the bound key code

    - `listener`: the listener to remove

    Specified by:
      `removeKeyListener` in interface `TopLevelContainer`

  - ### isEditing

    public boolean isEditing()

    Checks if the component is currently being edited.

    ###### Returns

    True if the component is currently being edited.

    ###### See also

    - #startEditingAsync()

    - #stopEditing(java.lang.Runnable)

    - #isEditable()

    - #getEditingDelegate()

    - #setEditingDelegate(com.codename1.ui.Editable)

    Specified by:
      `isEditing` in interface `Editable`
    Specified by:
      `isEditing` in interface `TopLevelContainer`
    Overrides:
      `isEditing` in class `Component`

  - ### stopEditing

    public void stopEditing(Runnable onFinish)

    Stops the editing process.

    ###### Parameters

    - `onFinish`: Callback called when the editing is complete.

    ###### See also

    - #startEditingAsync()

    - #isEditing()

    - #isEditable()

    - #getEditingDelegate()

    - #setEditingDelegate(com.codename1.ui.Editable)

    Specified by:
      `stopEditing` in interface `Editable`
    Specified by:
      `stopEditing` in interface `TopLevelContainer`
    Overrides:
      `stopEditing` in class `Component`

  - ### findCurrentlyEditingComponent

    public Component findCurrentlyEditingComponent()

    Returns the component currently being edited.

    ###### Returns

    the edited component, or null when nothing is being edited

    Specified by:
      `findCurrentlyEditingComponent` in interface `TopLevelContainer`

  - ### getCurrentInputDevice

    public VirtualInputDevice getCurrentInputDevice()

    Returns the virtual input device currently open for this top level.

    ###### Returns

    the open input device, or null when none is open

    Specified by:
      `getCurrentInputDevice` in interface `TopLevelContainer`

  - ### setCurrentInputDevice

    public void setCurrentInputDevice(VirtualInputDevice device) throws Exception

    Opens a virtual input device, closing whichever one was open before it.

    ###### Parameters

    - `device`: the device to open, or null to close the current one

    ###### Throws

    - `Exception`: if the previously open device failed to close
    Specified by:
      `setCurrentInputDevice` in interface `TopLevelContainer`
    Throws:
      `Exception`

  - ### getUIManager

    public UIManager getUIManager()

    This method should be used by the Component to retrieve the correct UIManager to work with

    ###### Returns

    a UIManager instance

    Specified by:
      `getUIManager` in interface `TopLevelContainer`
    Overrides:
      `getUIManager` in class `Container`

  - ### setUIManager

    public void setUIManager(UIManager uiManager)

    Allows replacing the UIManager in a component hierarchy to update the look and feel only to a specific hierarchy

    ###### Parameters

    - `uiManager`: UIManager instance
    Specified by:
      `setUIManager` in interface `TopLevelContainer`
    Overrides:
      `setUIManager` in class `Container`

  - ### getSafeArea

    public Rectangle getSafeArea()

    Returns the region of this top level that is guaranteed not to be obscured by system chrome such as a notch or a rounded corner.

    ###### Returns

    the safe area rectangle

    A desktop window has no notch or rounded corner to avoid, so the safe area is the whole window.

    Specified by:
      `getSafeArea` in interface `TopLevelContainer`

  - ### getInvisibleAreaUnderVKB

    public int getInvisibleAreaUnderVKB()

    Returns the height hidden behind the virtual keyboard, which is zero on a platform without one.

    ###### Returns

    the obscured height in pixels

    Always zero: a desktop window has no virtual keyboard overlaying it.

    Specified by:
      `getInvisibleAreaUnderVKB` in interface `TopLevelContainer`

  - ### getDragRegionStatus

    public int getDragRegionStatus(int x, int y)

    Indicates if the section within the X/Y area is a "drag region" where we expect people to drag or press in which case we can instantly start dragging making perceived performance faster. This is invoked by the implementation code to optimize drag start behavior

    ###### Parameters

    - `x`: x location for the touch

    - `y`: y location for the touch

    ###### Returns

    one of the DRAG_REGION_* values

    Specified by:
      `getDragRegionStatus` in interface `TopLevelContainer`
    Overrides:
      `getDragRegionStatus` in class `Component`

  - ### isEnableCursors

    public boolean isEnableCursors()

    Returns true when components may change the mouse cursor.

    ###### Returns

    true if cursors are enabled

    Specified by:
      `isEnableCursors` in interface `TopLevelContainer`

  - ### setEnableCursors

    public void setEnableCursors(boolean e)

    Sets whether components may change the mouse cursor.

    ###### Parameters

    - `e`: true to enable cursors
    Specified by:
      `setEnableCursors` in interface `TopLevelContainer`

  - ### getTextSelection

    public TextSelection getTextSelection()

    Returns the text selection support for this top level.

    ###### Returns

    the text selection

    Specified by:
      `getTextSelection` in interface `TopLevelContainer`

  - ### setResizable

    public void setResizable(boolean resizable)

    Sets whether the user may resize this window.

    ###### Parameters

    - `resizable`: true to allow resizing

  - ### isResizable

    public boolean isResizable()

    Indicates whether the user may resize this window.

    ###### Returns

    true if the window is resizable

  - ### setDecorated

    public void setDecorated(boolean decorated)

    Sets whether the platform draws a title bar and border for this window.

    An undecorated window paired with a `Toolbar` is how an application draws its own chrome.

    ###### Parameters

    - `decorated`: true for native decorations

  - ### isDecorated

    public boolean isDecorated()

    Indicates whether the platform draws this window's chrome.

    ###### Returns

    true if the window is natively decorated

  - ### setAlwaysOnTop

    public void setAlwaysOnTop(boolean alwaysOnTop)

    Keeps this window above the application's other windows.

    ###### Parameters

    - `alwaysOnTop`: true to float the window

  - ### isAlwaysOnTop

    public boolean isAlwaysOnTop()

    Indicates whether this window floats above the others.

    ###### Returns

    true if the window is always on top

  - ### setUtilityWindow

    public void setUtilityWindow(boolean utility)

    Marks this window as a palette or tool window, which the platform typically keeps out of the task bar.

    ###### Parameters

    - `utility`: true for a utility window

  - ### isUtilityWindow

    public boolean isUtilityWindow()

    Indicates whether this is a utility window.

    ###### Returns

    true for a utility window

  - ### setWindowIcon

    public void setWindowIcon(Image icon)

    Sets the icon the platform shows for this window.

    ###### Parameters

    - `icon`: the icon to display

  - ### getWindowIcon

    public Image getWindowIcon()

    Returns the icon the platform shows for this window.

    ###### Returns

    the window icon, or null when none was set

  - ### getWindowBounds

    public Rectangle getWindowBounds()

    Returns this window's bounds in desktop coordinates, including any native chrome.

    This is a different coordinate space from `Component#getWidth()` and `Component#getHeight()`, which report the Codename One content size.

    ###### Returns

    the native window bounds

  - ### setWindowBounds

    public void setWindowBounds(Rectangle r)

    Moves and resizes this window.

    ###### Parameters

    - `r`: the new bounds in desktop coordinates

  - ### setWindowSize

    public void setWindowSize(int width, int height)

    Resizes this window, leaving its position alone.

    ###### Parameters

    - `width`: the new width

    - `height`: the new height

  - ### setWindowLocation

    public void setWindowLocation(int x, int y)

    Moves this window, leaving its size alone.

    ###### Parameters

    - `x`: the new x position in desktop coordinates

    - `y`: the new y position in desktop coordinates

  - ### setMinimumWindowSize

    public void setMinimumWindowSize(Dimension d)

    Sets the smallest size the user may resize this window to.

    ###### Parameters

    - `d`: the minimum size

  - ### getMinimumWindowSize

    public Dimension getMinimumWindowSize()

    Returns the smallest size the user may resize this window to.

    ###### Returns

    the minimum size, or null when none was set

  - ### centerOnDesktop

    public void centerOnDesktop()
    Centres this window on the work area of the monitor it sits on, so it does not land under the task bar or dock.

  - ### centerOn

    public void centerOn(TopLevelContainer other)

    Centres this window over another top level.

    ###### Parameters

    - `other`: the top level to centre over

  - ### minimize

    public void minimize()
    Minimizes this window.

  - ### restore

    public void restore()

    Restores this window from a minimized state.

    A window the application hid is not minimized and is not brought back by this. `#hide()` leaves the peer alive with the hierarchy invisible, so handing that peer to the platform's restore puts the native window back on screen while the framework still counts it as hidden -- and nothing ever repaints it, because the paint loop skips a window that is not showing. The result is a blank or stale window that `#isWindowShowing()` denies is there. Bringing a hidden window back is `#show()`'s job, which restores the whole lifecycle rather than just the native state.

  - ### toggleMaximize

    public void toggleMaximize()
    Toggles this window between maximized and its previous size.

  - ### requestWindowFocus

    public void requestWindowFocus()
    Raises this window and gives it keyboard focus.

  - ### isWindowFocused

    public boolean isWindowFocused()

    Indicates whether this window currently holds keyboard focus.

    ###### Returns

    true if this window is focused

  - ### getMonitor

    public Monitor getMonitor()

    Returns the monitor this window currently sits on.

    ###### Returns

    the monitor showing this window

  - ### getDensity

    public int getDensity()

    Returns the density of the monitor this window sits on, which on a mixed resolution desktop is not necessarily the density `Display` reports.

    ###### Returns

    the density constant for this window's monitor

  - ### getScale

    public double getScale()

    Returns the backing scale of the monitor this window sits on.

    ###### Returns

    the scale factor for this window's monitor

  - ### show

    public void show()
    Shows this window, creating the native window the first time it is called.
    Specified by:
      `show` in interface `TopLevelContainer`

  - ### showModal

    public void showModal()

    Shows this window and blocks the calling code until it stops being on screen -- whether that is `#dispose()` or `#hide()`.

    Hiding ends the wait as surely as disposing does, and that is deliberate: the window is closed as far as the user is concerned, and parking the caller on a window nobody can see or reach would hang it. `#HIDE_ON_CLOSE` reaches this path, so a modal window with that close operation returns here still live and reusable. Code that runs cleanup after this returns should therefore ask `#isWindowDisposed()` rather than assume it -- the window may be waiting to be shown again. Minimizing does not end the wait; a minimized window is still up.

    This uses the same mechanism as a modal `Dialog`: the caller is parked while the event dispatch thread keeps running, so every other window carries on painting and animating. Input to the windows this one blocks is dropped by the framework, so modality behaves the same way on every platform whether or not the platform implements its own.

  - ### setModalityType

    public void setModalityType(int type)

    Sets how this window blocks input to the others.

    ###### Parameters

    - `type`: one of `#MODALITY_NONE`, `#MODALITY_WINDOW` or `#MODALITY_APPLICATION`

  - ### getModalityType

    public int getModalityType()

    Returns how this window blocks input to the others.

    ###### Returns

    the modality type

  - ### hide

    public void hide()
    Hides this window without destroying it, so it can be shown again.

  - ### isWindowShowing

    public boolean isWindowShowing()

    Indicates whether this window is currently mapped on screen.

    ###### Returns

    true if the window is showing

  - ### dispose

    public void dispose()
    Destroys this window and releases the native window behind it. Calling this more than once is harmless.

  - ### isWindowDisposed

    public boolean isWindowDisposed()

    Indicates whether this window has been disposed.

    ###### Returns

    true once `#dispose()` has run

  - ### hasPaintedOnce

    public boolean hasPaintedOnce()

    Indicates whether this window has completed at least one paint cycle, and so whether its content -- rather than an empty surface -- is what a capture would return.

    A window's raster exists from the moment it is shown, so capturing before the first paint yields a blank frame of the right size rather than a failure. Test and tooling code that wants the content should wait on this.

    ###### Returns

    true once the window has painted

  - ### capture

    public Image capture()

    Captures this window's current contents.

    The ordinary `Display#screenshot(com.codename1.util.SuccessCallback)` can only see the application's main surface, so a window has to be captured through the window manager instead. This is what the windowed screenshot tests use.

    ###### Returns

    an image of the window, or null when the port cannot capture one

  - ### setCloseOperation

    public void setCloseOperation(int op)

    Sets what happens when the user closes this window through the platform's own close control.

    ###### Parameters

    - `op`: one of `#DISPOSE_ON_CLOSE`, `#HIDE_ON_CLOSE` or `#DO_NOTHING_ON_CLOSE`

  - ### getCloseOperation

    public int getCloseOperation()

    Returns what happens when the user closes this window.

    ###### Returns

    the close operation

  - ### setOwnerWindow

    public void setOwnerWindow(TopLevelContainer owner)

    Sets the top level that owns this window. An owned window stays above its owner and is disposed with it.

    The name avoids `setOwner`, which `Component` already uses for an unrelated hit testing mechanism.

    ###### Parameters

    - `owner`: the owning top level

  - ### getOwnerWindow

    public TopLevelContainer getOwnerWindow()

    Returns the top level that owns this window.

    ###### Returns

    the owner, or null when the window is unowned

  - ### addShowListener

    public void addShowListener(ActionListener l)

    Adds a listener notified whenever this top level is shown.

    ###### Parameters

    - `l`: the listener to add
    Specified by:
      `addShowListener` in interface `TopLevelContainer`

  - ### removeShowListener

    public void removeShowListener(ActionListener l)

    Removes a previously added show listener.

    ###### Parameters

    - `l`: the listener to remove
    Specified by:
      `removeShowListener` in interface `TopLevelContainer`

  - ### addSizeChangedListener

    public void addSizeChangedListener(ActionListener l)

    Adds a listener notified whenever this top level changes size.

    ###### Parameters

    - `l`: the listener to add
    Specified by:
      `addSizeChangedListener` in interface `TopLevelContainer`

  - ### removeSizeChangedListener

    public void removeSizeChangedListener(ActionListener l)

    Removes a previously added size changed listener.

    ###### Parameters

    - `l`: the listener to remove
    Specified by:
      `removeSizeChangedListener` in interface `TopLevelContainer`

  - ### addCloseListener

    public void addCloseListener(ActionListener l)

    Adds a listener notified when the user tries to close this window. Consuming the event vetoes the close.

    ###### Parameters

    - `l`: the listener to add

  - ### removeCloseListener

    public void removeCloseListener(ActionListener l)

    Removes a previously added close listener.

    ###### Parameters

    - `l`: the listener to remove

  - ### addWindowListener

    public void addWindowListener(ActionListener l)

    Adds a listener notified when this window is shown, hidden, moved or resized.

    ###### Parameters

    - `l`: the listener to add

  - ### removeWindowListener

    public void removeWindowListener(ActionListener l)

    Removes a previously added window listener.

    ###### Parameters

    - `l`: the listener to remove

  - ### paint

    public void paint(Graphics g)

    This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.

    ###### Parameters

    - `g`: the component graphics
    Specified by:
      `paint` in interface `Animation`
    Overrides:
      `paint` in class `Container`

  - ### getSideGap

    public int getSideGap()

    Returns the gap to be left for the side scrollbar on the Y axis. This method is used by layout managers to determine the room they should leave for the scrollbar. (note: side scrollbar rather than left scrollbar is used for a future version that would support bidi).

    ###### Returns

    the gap to be left for the side scrollbar on the Y axis

    Overrides:
      `getSideGap` in class `Container`

  - ### pointerPressed

    public void pointerPressed(int x, int y)

    If this Component is focused, the pointer pressed event will call this method

    ###### Parameters

    - `x`: the pointer x coordinate

    - `y`: the pointer y coordinate

    A `Container` has no hit testing of its own -- `Form` does that work itself -- so a `Window` has to as well, or a press would never reach the component under it. This is the same walk `Form` performs, without the menu bar special case a window has no equivalent of.

    Overrides:
      `pointerPressed` in class `Container`

  - ### pointerDragged

    public void pointerDragged(int x, int y)

    If this Component is focused, the pointer dragged event will call this method

    ###### Parameters

    - `x`: the pointer x coordinate

    - `y`: the pointer y coordinate

    Overrides:
      `pointerDragged` in class `Component`

  - ### pointerDragged

    public void pointerDragged(int[] x, int[] y)

    If this Component is focused, the pointer dragged event will call this method

    ###### Parameters

    - `x`: the pointer x coordinate

    - `y`: the pointer y coordinate

    The multi pointer form, which is how a pinch reaches the component under the fingers. Without it `Component`'s version runs instead: it tests the pinch on the window itself and then collapses the event to a single coordinate, so the pressed child gets an ordinary one-finger drag and never its `pinch` callbacks.

    Overrides:
      `pointerDragged` in class `Component`

  - ### pointerReleased

    public void pointerReleased(int x, int y)

    If this Component is focused, the pointer released event will call this method

    ###### Parameters

    - `x`: the pointer x coordinate

    - `y`: the pointer y coordinate

    Overrides:
      `pointerReleased` in class `Component`

  - ### longKeyPress

    protected void longKeyPress(int keyCode)

    If this Component is focused this method is invoked when the user presses and holds the key

    ###### Parameters

    - `keyCode`: the key code value to indicate a physical key.

    The keyboard counterpart of `#longPointerPress(int, int)`, and broken the same way: `Display` dispatches a long key press to the top level, `Component`'s implementation is empty, so holding a key inside a window reached nothing. Found by checking what else shares that dispatch site rather than waiting for it to be reported.

    Overrides:
      `longKeyPress` in class `Component`

  - ### longPointerPress

    public void longPointerPress(int x, int y)

    If this Component is focused this method is invoked when the user presses and holds the pointer on the Component

    `Component`'s implementation only fires listeners attached to this window, so without this a long press on a button inside a window reached nothing -- neither the component nor its context menu.

    Overrides:
      `longPointerPress` in class `Component`

  - ### pointerHover

    public void pointerHover(int[] x, int[] y)

    Invoked for devices where the pointer can hover without actually clicking the display. This is true for PC mouse pointer as well as some devices such as the BB storm.

    ###### Parameters

    - `x`: the pointer x coordinate

    - `y`: the pointer y coordinate

    `Component`'s implementation is empty, so without this a window would receive hover events and drop them: no tooltips, and no hover state on the components under the pointer.

    Overrides:
      `pointerHover` in class `Component`

  - ### pointerHoverReleased

    public void pointerHoverReleased(int[] x, int[] y)

    Invoked for devices where the pointer can hover without actually clicking the display. This is true for PC mouse pointer as well as some devices such as the BB storm.

    ###### Parameters

    - `x`: the pointer x coordinate

    - `y`: the pointer y coordinate

    Overrides:
      `pointerHoverReleased` in class `Component`

  - ### pointerHoverPressed

    public void pointerHoverPressed(int[] x, int[] y)

    Invoked for devices where the pointer can hover without actually clicking the display. This is true for PC mouse pointer as well as some devices such as the BB storm.

    ###### Parameters

    - `x`: the pointer x coordinate

    - `y`: the pointer y coordinate

    Overrides:
      `pointerHoverPressed` in class `Component`

  - ### addComponentAwaitingRelease

    public <C extends Component> void addComponentAwaitingRelease(C c)

    Returns this top level as a `Container`.

    A Java interface cannot extend a class, so without this a `TopLevelContainer` reference could not be handed to anything expecting a `Component`.

    ###### Returns

    this instance, as a `Container` Records a component that is waiting for a pointer release, so the top level can release it if the gesture ends somewhere else.

    ###### Parameters

    - `c`: the component awaiting a release
    Specified by:
      `addComponentAwaitingRelease` in interface `TopLevelContainer`

  - ### removeComponentAwaitingRelease

    public <C extends Component> void removeComponentAwaitingRelease(C c)

    Stops tracking a component that was waiting for a pointer release.

    ###### Parameters

    - `c`: the component to stop tracking
    Specified by:
      `removeComponentAwaitingRelease` in interface `TopLevelContainer`

  - ### clearComponentsAwaitingRelease

    public void clearComponentsAwaitingRelease()
    Drops every component waiting for a pointer release, used when a gesture is taken over by something else -- a pull to refresh, for instance.
    Specified by:
      `clearComponentsAwaitingRelease` in interface `TopLevelContainer`

  - ### keyPressed

    public void keyPressed(int keyCode)

    If this Component is focused, the key pressed event will call this method

    ###### Parameters

    - `keyCode`: the key code value to indicate a physical key.

    A window dispatches keys itself, exactly as `Form` does. Inheriting `Container`'s handler instead only forwards to a lead component, so the focused component would never see a key, arrow traversal would not work and nothing registered through `#addKeyListener(int, ActionListener)` would ever fire.

    This is the same shape as `Form#keyPressed(int)` minus the menu bar, which a window does not have: commands reach the desktop menu instead.

    Overrides:
      `keyPressed` in class `Container`

  - ### keyReleased

    public void keyReleased(int keyCode)

    If this Component is focused, the key released event will call this method

    ###### Parameters

    - `keyCode`: the key code value to indicate a physical key.
    Overrides:
      `keyReleased` in class `Container`

  - ### keyRepeated

    public void keyRepeated(int keyCode)

    If this Component is focused, the key repeat event will call this method.

    ###### Parameters

    - `keyCode`: the key code value to indicate a physical key.
    Overrides:
      `keyRepeated` in class `Component`

  - ### addComponent

    public void addComponent(Component cmp)

    Adds a Component to the Container

    ###### Parameters

    - `cmp`: the component to be added

    Adds to the content pane, mirroring `Form`, so `window.add(cmp)` means `window.getContentPane().add(cmp)`. Container's add() is final and routes through here, so overriding addComponent covers both.

    Overrides:
      `addComponent` in class `Container`

  - ### addComponent

    public void addComponent(Object constraints, Component cmp)

    Adds a Component to the Container

    ###### Parameters

    - `constraints`: @param constraints this method is useful when the Layout requires a constraint such as the BorderLayout. In this case you need to specify an additional data when you add a Component, such as "CENTER", "NORTH"...

    - `cmp`: component to add

    Overrides:
      `addComponent` in class `Container`

  - ### addComponent

    public void addComponent(int index, Component cmp)

    This method adds the Component at a specific index location in the Container Components array.

    ###### Parameters

    - `index`: location to insert the Component

    - `cmp`: the Component to add

    ###### Throws

    - `ArrayIndexOutOfBoundsException`: if index is out of bounds

    - `IllegalArgumentException`: @throws IllegalArgumentException if Component is already contained or the cmp is a Form Component

    The indexed overloads need delegating too. They are separate methods rather than paths through the two above, so without these an indexed add put the component in the window root beside the title area and the content pane -- where the root's own BorderLayout would place it, and where `#getContentPane()` cannot see it.

    Overrides:
      `addComponent` in class `Container`

  - ### addComponent

    public void addComponent(int index, Object constraints, Component cmp)

    Adds a Component to the Container

    ###### Parameters

    - `index`: location to insert the Component

    - `constraints`: @param constraints this method is useful when the Layout requires a constraint such as the BorderLayout. In this case you need to specify an additional data when you add a Component, such as "CENTER", "NORTH"...

    - `cmp`: component to add

    Overrides:
      `addComponent` in class `Container`

  - ### removeComponent

    public void removeComponent(Component cmp)

    removes a Component from the Container, notice that removed component might still have a pending repaint in the queue that won't be removed. Calling form.repaint() will workaround such an issue.

    ###### Parameters

    - `cmp`: the removed component
    Overrides:
      `removeComponent` in class `Container`

  - ### removeAll

    public void removeAll()
    remove all Components from container, notice that removed component might still have a pending repaint in the queue that won't be removed. Calling form.repaint() will workaround such an issue. Notice that this method doesn't recurse and only removes from the current container.
    Overrides:
      `removeAll` in class `Container`

  - ### getComponentIndex

    public int getComponentIndex(Component cmp)

    Returns the Component index in the Container

    ###### Parameters

    - `cmp`: the component to search for

    ###### Returns

    the Component index in the Container or -1 if not found

    Overrides:
      `getComponentIndex` in class `Container`

  - ### replace

    public void replace(Component current, Component next, Transition t)

    This method replaces the current Component with the next Component. Current Component must be contained in this Container. This method return immediately.

    ###### Parameters

    - `current`: a Component to remove from the Container

    - `next`: a Component that replaces the current Component

    - `t`: @param t a Transition between the add and removal of the Components a Transition can be null

    Overrides:
      `replace` in class `Container`

  - ### replaceAndWait

    public void replaceAndWait(Component current, Component next, Transition t)

    This method replaces the current Component with the next Component. Current Component must be contained in this Container. This method returns when transition has finished.

    ###### Parameters

    - `current`: a Component to remove from the Container

    - `next`: a Component that replaces the current Component

    - `t`: @param t a Transition between the add and removal of the Components a Transition can be null

    Overrides:
      `replaceAndWait` in class `Container`

  - ### animateLayout

    public void animateLayout(int duration)

    Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation

    See:

        Form hi = new Form("Layout Animations", new BoxLayout(BoxLayout.Y_AXIS));
        Button fall = new Button("Fall");
        fall.addActionListener((e) -> {
            for(int iter = 0 ; iter < 10 ; iter++) {
                Label b = new Label ("Label " + iter);
                b.setWidth(fall.getWidth());
                b.setHeight(fall.getHeight());
                b.setY(-fall.getHeight());
                hi.add(b);
            }
            hi.getContentPane().animateLayout(20000);
        });
        hi.add(fall);

    ###### Parameters

    - `duration`: the duration in milliseconds for the animation
    Overrides:
      `animateLayout` in class `Container`

  - ### animateLayoutAndWait

    public void animateLayoutAndWait(int duration)

    Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation. This method waits until the operation is completed before returning

    ###### Parameters

    - `duration`: the duration in milliseconds for the animation
    Overrides:
      `animateLayoutAndWait` in class `Container`

  - ### animateLayoutFade

    public void animateLayoutFade(int duration, int startingOpacity)

    Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation

    ###### Parameters

    - `duration`: the duration in milliseconds for the animation

    - `startingOpacity`: the initial opacity to give to the animated components

    Overrides:
      `animateLayoutFade` in class `Container`

  - ### animateLayoutFadeAndWait

    public void animateLayoutFadeAndWait(int duration, int startingOpacity)

    Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation. This method waits until the operation is completed before returning

    ###### Parameters

    - `duration`: the duration in milliseconds for the animation

    - `startingOpacity`: the initial opacity to give to the animated components

    Overrides:
      `animateLayoutFadeAndWait` in class `Container`

  - ### animateHierarchy

    public void animateHierarchy(int duration)

    Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation

    ###### Parameters

    - `duration`: the duration in milliseconds for the animation
    Overrides:
      `animateHierarchy` in class `Container`

  - ### animateHierarchyAndWait

    public void animateHierarchyAndWait(int duration)

    Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation. This method waits until the operation is completed before returning

    ###### Parameters

    - `duration`: the duration in milliseconds for the animation
    Overrides:
      `animateHierarchyAndWait` in class `Container`

  - ### animateHierarchyFade

    public void animateHierarchyFade(int duration, int startingOpacity)

    Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation

    ###### Parameters

    - `duration`: the duration in milliseconds for the animation

    - `startingOpacity`: the initial opacity to give to the animated components

    Overrides:
      `animateHierarchyFade` in class `Container`

  - ### animateHierarchyFadeAndWait

    public void animateHierarchyFadeAndWait(int duration, int startingOpacity)

    Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation. This method waits until the operation is completed before returning

    ###### Parameters

    - `duration`: the duration in milliseconds for the animation

    - `startingOpacity`: the initial opacity to give to the animated components

    Overrides:
      `animateHierarchyFadeAndWait` in class `Container`

  - ### animateUnlayout

    public void animateUnlayout(int duration, int opacity, Runnable callback)

    This method is the exact reverse of animateLayout, when completed it leaves the container in an invalid state. It is useful to invoke this in order to remove a component, transition to a different form or provide some other interaction. E.g.:

        Form hi = new Form("Layout Animations", new BoxLayout(BoxLayout.Y_AXIS));
        Button fall = new Button("Fall");
        fall.addActionListener((e) -> {
            if(hi.getContentPane().getComponentCount() == 1) {
                fall.setText("Rise");
                for(int iter = 0 ; iter  {
                    hi.removeAll();
                    hi.add(fall);
                    hi.revalidate();
                });*/

            }
        });
        hi.add(fall);

    ###### Parameters

    - `duration`: the duration of the animation

    - `opacity`: the opacity to which the layout will reach, allows fading out the components

    - `callback`: if not null will be invoked when unlayouting is complete

    Overrides:
      `animateUnlayout` in class `Container`

  - ### animateUnlayoutAndWait

    public void animateUnlayoutAndWait(int duration, int opacity)

    This method is the exact reverse of animateLayoutAndWait, when completed it leaves the container in an invalid state. It is useful to invoke this in order to remove a component, transition to a different form or provide some other interaction. E.g.:

        Form hi = new Form("Layout Animations", new BoxLayout(BoxLayout.Y_AXIS));
        Button fall = new Button("Fall");
        fall.addActionListener((e) -> {
            if(hi.getContentPane().getComponentCount() == 1) {
                fall.setText("Rise");
                for(int iter = 0 ; iter  {
                    hi.removeAll();
                    hi.add(fall);
                    hi.revalidate();
                });*/

            }
        });
        hi.add(fall);

    ###### Parameters

    - `duration`: the duration of the animation

    - `opacity`: the opacity to which the layout will reach, allows fading out the components

    Overrides:
      `animateUnlayoutAndWait` in class `Container`

  - ### getLayout

    public Layout getLayout()

    Returns the layout manager responsible for arranging this container.

    ###### Returns

    the container layout manager

    Overrides:
      `getLayout` in class `Container`

  - ### setLayout

    public void setLayout(Layout layout)

    Sets the layout manager responsible for arranging this container

    ###### Parameters

    - `layout`: the specified layout manager
    Overrides:
      `setLayout` in class `Container`

  - ### isScrollable

    public boolean isScrollable()

    Indicates whether the component should/could scroll by default a component is not scrollable.

    ###### Returns

    whether the component is scrollable

    Overrides:
      `isScrollable` in class `Component`

  - ### setScrollable

    public void setScrollable(boolean scrollable)

    The equivalent of calling both setScrollableY and setScrollableX

    ###### Parameters

    - `scrollable`: @param scrollable whether the component should/could scroll on the X and Y axis

    ###### Deprecated

    use setScrollableX and setScrollableY instead. This method is deprecated since it breeds confusion and is often misunderstood.

    Overrides:
      `setScrollable` in class `Container`

  - ### setRTL

    public void setRTL(boolean r)

    Is the component a bidi RTL component

    ###### Parameters

    - `rtl`: true if the component should work in a right to left mode

    Forwarded to the content pane as well as the window root: the application's layout runs in the content pane, so setting it on the root alone left directional layouts and alignment reversed while `isRTL()` reported true.

    Overrides:
      `setRTL` in class `Component`

  - ### isScrollableX

    public boolean isScrollableX()

    Indicates whether the component should/could scroll on the X axis

    ###### Returns

    whether the component is scrollable on the X axis

    Overrides:
      `isScrollableX` in class `Container`

  - ### setScrollableX

    public void setScrollableX(boolean scrollableX)

    Sets whether the component should/could scroll on the X axis

    ###### Parameters

    - `scrollableX`: whether the component should/could scroll on the X axis
    Overrides:
      `setScrollableX` in class `Container`

  - ### isScrollableY

    public boolean isScrollableY()

    Indicates whether the component should/could scroll on the Y axis

    ###### Returns

    whether the component is scrollable on the X axis

    Overrides:
      `isScrollableY` in class `Container`

  - ### setScrollableY

    public void setScrollableY(boolean scrollableY)

    Sets whether the component should/could scroll on the Y axis

    ###### Parameters

    - `scrollableY`: whether the component should/could scroll on the Y axis
    Overrides:
      `setScrollableY` in class `Container`

  - ### isScrollVisible

    public boolean isScrollVisible()

    Indicate whether this component scroll is visible

    ###### Returns

    true is this component scroll is visible; otherwise false

    Overrides:
      `isScrollVisible` in class `Component`

  - ### setScrollVisible

    public void setScrollVisible(boolean scrollVisible)

    Set whether this component scroll is visible

    ###### Parameters

    - `isScrollVisible`: Indicate whether this component scroll is visible
    Overrides:
      `setScrollVisible` in class `Component`

  - ### isSmoothScrolling

    public boolean isSmoothScrolling()

    Indicates that scrolling through the component should work as an animation

    ###### Returns

    whether this component use smooth scrolling

    Overrides:
      `isSmoothScrolling` in class `Component`

  - ### setSmoothScrolling

    public void setSmoothScrolling(boolean smoothScrolling)

    Indicates that scrolling through the component should work as an animation

    ###### Parameters

    - `smoothScrolling`: indicates if a component uses smooth scrolling
    Overrides:
      `setSmoothScrolling` in class `Component`

  - ### getScrollAnimationSpeed

    public int getScrollAnimationSpeed()

    Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode

    ###### Returns

    scroll animation speed in milliseconds

    Overrides:
      `getScrollAnimationSpeed` in class `Component`

  - ### setScrollAnimationSpeed

    public void setScrollAnimationSpeed(int animationSpeed)

    Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode

    ###### Parameters

    - `animationSpeed`: scroll animation speed in milliseconds
    Overrides:
      `setScrollAnimationSpeed` in class `Component`

  - ### isAlwaysTensile

    public boolean isAlwaysTensile()

    Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)

    ###### Returns

    the alwaysTensile

    Overrides:
      `isAlwaysTensile` in class `Component`

  - ### setAlwaysTensile

    public void setAlwaysTensile(boolean alwaysTensile)

    Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)

    ###### Parameters

    - `alwaysTensile`: the alwaysTensile to set
    Overrides:
      `setAlwaysTensile` in class `Component`