public class Window
ImplementsAnimation, Editable, Iterable<Component>, StyleListener, 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.
Fields
public static final int DISPOSE_ON_CLOSE = 0 | Closing the window disposes it and releases the native window. |
public static final int HIDE_ON_CLOSE = 1 | Closing the window hides it, leaving it able to be shown again. |
public static final int DO_NOTHING_ON_CLOSE = 2 | Closing the window does nothing, leaving the application to call #dispose() itself from a close listener. |
public static final int MODALITY_NONE = 0 | The window does not block input to any other window. |
public static final int MODALITY_WINDOW = 1 | The window blocks input to the window that owns it. |
public static final int MODALITY_APPLICATION = 2 | The window blocks input to every other window and to the main form. |
Constructors
public Window() | Creates a window whose content is laid out with a FlowLayout. |
public Window(Layout contentPaneLayout) | Creates a window with the given content layout. |
public Window(String title) | Creates a window with the given title, laid out with a FlowLayout. |
public Window(String title, Layout contentPaneLayout) | Creates a window with the given title and content layout. |
Methods
public int getWindowId() | Returns the framework assigned id of this window. |
public Container asContainer() | |
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. |
public Container getContentPane() | Returns the container holding the application content of this top level. |
public Container getLayeredPane() | Returns the layered pane covering the content area, creating it if needed. |
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. |
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. |
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. |
public Painter getGlassPane() | Returns the painter drawn above everything else in this top level. |
public void setGlassPane(Painter glassPane) | Sets the painter drawn above everything else in this top level. |
public String getTitle() | Returns the title text. |
public void setTitle(String title) | Sets the title text. |
public void addCommand(Command cmd) | Adds a command to this top level. |
public void removeCommand(Command cmd) | Removes a command from this top level. |
public void removeAllCommands() | Removes every command from this top level. |
public int getCommandCount() | Returns the number of commands. |
public Command getCommand(int index) | Returns the command at the given offset. |
public void addCommandListener(ActionListener l) | Adds a listener notified when a command is activated. |
public void removeCommandListener(ActionListener l) | Removes a previously added command listener. |
public boolean isTopLevelShowing() | Whether this top level is the one currently on screen. |
public 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. |
public AnimationManager getAnimationManager() | |
public void registerAnimated(Animation cmp) | Registers an animation that is invoked on every frame of this top level. |
public void deregisterAnimated(Animation cmp) | Removes a previously registered animation. |
public boolean grabAnimationLock() | Takes the animation lock, blocking until no animation is in progress. |
public void releaseAnimationLock() | Releases a previously taken animation lock. |
public Component getFocused() | Returns the component owning focus within this top level. |
public void setFocused(Component focused) | Moves focus to the given component. |
public boolean isCyclicFocus() | Returns true when focus traversal wraps around at the edges. |
public void setCyclicFocus(boolean cyclicFocus) | Sets whether focus traversal wraps around at the edges. |
public boolean isSingleFocusMode() | Returns true when only one component in this top level can take focus. |
public Form.TabIterator getTabIterator(Component start) | Returns an iterator walking the components in traversal order. |
public void scrollComponentToVisible(Component c) | Makes sure the component is visible in the scroll if this container is scrollable |
public void addKeyListener(int keyCode, ActionListener listener) | Adds a key binding scoped to this top level. |
public void removeKeyListener(int keyCode, ActionListener listener) | Removes a previously added key binding. |
public boolean isEditing() | Checks if the component is currently being edited. |
public void stopEditing(Runnable onFinish) | Stops the editing process. |
public Component findCurrentlyEditingComponent() | Returns the component currently being edited. |
public VirtualInputDevice getCurrentInputDevice() | Returns the virtual input device currently open for this top level. |
public void setCurrentInputDevice(VirtualInputDevice device)
throws Exception | Opens a virtual input device, closing whichever one was open before it. |
public UIManager getUIManager() | This method should be used by the Component to retrieve the correct UIManager to work with |
public void setUIManager(UIManager uiManager) | Allows replacing the UIManager in a component hierarchy to update the look and feel only to a specific hierarchy |
public int getTintColor() | 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. |
public void refreshTheme(boolean merge) | Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME! |
public void setTintColor(int tintColor) | Sets the colour painted over this top level while a dialog or menu covers it. |
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. |
public int getInvisibleAreaUnderVKB() | Returns the area of this component that is currently hidden by the virtual keyboard. |
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. |
public boolean isEnableCursors() | Returns true when components may change the mouse cursor. |
public void setEnableCursors(boolean e) | Sets whether components may change the mouse cursor. |
public TextSelection getTextSelection() | Returns the text selection support for this top level. |
public void setResizable(boolean resizable) | Sets whether the user may resize this window. |
public boolean isResizable() | Indicates whether the user may resize this window. |
public void setDecorated(boolean decorated) | Sets whether the platform draws a title bar and border for this window. |
public boolean isDecorated() | Indicates whether the platform draws this window’s chrome. |
public void setAlwaysOnTop(boolean alwaysOnTop) | Keeps this window above the application’s other windows. |
public boolean isAlwaysOnTop() | Indicates whether this window floats above the others. |
public void setUtilityWindow(boolean utility) | Marks this window as a palette or tool window, which the platform typically keeps out of the task bar. |
public boolean isUtilityWindow() | Indicates whether this is a utility window. |
public void setWindowIcon(Image icon) | Sets the icon the platform shows for this window. |
public Image getWindowIcon() | Returns the icon the platform shows for this window. |
public Rectangle getWindowBounds() | Returns this window’s bounds in desktop coordinates, including any native chrome. |
public void setWindowContentSize(int width, int height) | Sizes this window so its Codename One drawable area is the given size, rather than its native frame. |
public Rectangle getWorkAreaInPixels() | The usable area of this window’s display, in the device pixels a layout uses. |
public void setWindowBounds(Rectangle r) | |
public void setWindowSize(int width, int height) | Resizes this window, leaving its position alone. |
public void setWindowLocation(int x, int y) | Moves this window, leaving its size alone. |
public void setMinimumWindowSize(Dimension d) | Sets the smallest size the user may resize this window to. |
public Dimension getMinimumWindowSize() | Returns the smallest size the user may resize this window to. |
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. |
public void centerOn(TopLevelContainer other) | Centres this window over another top level. |
public void minimize() | Minimizes this window. |
public void restore() | Restores this window from a minimized state. |
public void toggleMaximize() | Toggles this window between maximized and its previous size. |
public void requestWindowFocus() | Raises this window and gives it keyboard focus. |
public boolean isWindowFocused() | Indicates whether this window currently holds keyboard focus. |
public Monitor getMonitor() | Returns the monitor this window currently sits on. |
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. |
public double getScale() | Returns the backing scale of the monitor this window sits on. |
public void show() | Shows this window, creating the native window the first time it is called. |
public void showModal() | Shows this window and blocks the calling code until it stops being on screen – whether that is #dispose() or #hide(). |
public void setModalityType(int type) | Sets how this window blocks input to the others. |
public int getModalityType() | Returns how this window blocks input to the others. |
public void hide() | Hides this window without destroying it, so it can be shown again. |
public boolean isWindowShowing() | Indicates whether this window is currently mapped on screen. |
public void dispose() | Destroys this window and releases the native window behind it. |
public boolean isWindowDisposed() | Indicates whether this window has been disposed. |
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. |
public Image capture() | Captures this window’s current contents. |
public void setCloseOperation(int op) | Sets what happens when the user closes this window through the platform’s own close control. |
public int getCloseOperation() | Returns what happens when the user closes this window. |
public void setOwnerWindow(TopLevelContainer owner) | Sets the top level that owns this window. |
public TopLevelContainer getOwnerWindow() | Returns the top level that owns this window. |
public void addShowListener(ActionListener l) | Adds a listener notified whenever this top level is shown. |
public void removeShowListener(ActionListener l) | Removes a previously added show listener. |
public void addSizeChangedListener(ActionListener l) | Adds a listener notified whenever this top level changes size. |
public void removeSizeChangedListener(ActionListener l) | Removes a previously added size changed listener. |
public void addCloseListener(ActionListener l) | Adds a listener notified when the user tries to close this window. |
public void removeCloseListener(ActionListener l) | Removes a previously added close listener. |
public void addWindowListener(ActionListener l) | Adds a listener notified when this window is shown, hidden, moved or resized. |
public void removeWindowListener(ActionListener l) | Removes a previously added window listener. |
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. |
public int getSideGap() | Returns the gap to be left for the side scrollbar on the Y axis. |
public void pointerPressed(int x, int y) | If this Component is focused, the pointer pressed event will call this method |
public void pointerDragged(int x, int y) | If this Component is focused, the pointer dragged event will call this method |
public void pointerDragged(int[] x, int[] y) | If this Component is focused, the pointer dragged event will call this method |
public void pointerReleased(int x, int y) | If this Component is focused, the pointer released 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 |
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 |
public void pointerHover(int[] x, int[] y) | Invoked for devices where the pointer can hover without actually clicking the display. |
public void pointerHoverReleased(int[] x, int[] y) | Invoked for devices where the pointer can hover without actually clicking the display. |
public void pointerHoverPressed(int[] x, int[] y) | Invoked for devices where the pointer can hover without actually clicking the display. |
public <C extends Component> void addComponentAwaitingRelease(C c) | Returns this top level as a Container. |
public <C extends Component> void removeComponentAwaitingRelease(C c) | Stops tracking a component that was waiting for a pointer release. |
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. |
public void keyPressed(int keyCode) | If this Component is focused, the key pressed event will call this method |
public void keyReleased(int keyCode) | If this Component is focused, the key released event will call this method |
public void keyRepeated(int keyCode) | If this Component is focused, the key repeat event will call this method. |
public void addComponent(Component cmp) | Adds a Component to the Container |
public void addComponent(Object constraints, Component cmp) | Adds a Component to the Container |
public void addComponent(int index, Component cmp) | This method adds the Component at a specific index location in the Container Components array. |
public void addComponent(int index, Object constraints, Component cmp) | Adds a Component to the Container |
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. |
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. |
public int getComponentIndex(Component cmp) | Returns the Component index in the Container |
public void setContent(Component content, Transition t) | Replaces this window’s content, animating the change. |
public void replace(Component current, Component next, Transition t) | This method replaces the current Component with the next Component. |
public void replaceAndWait(Component current, Component next, Transition t) | This method replaces the current Component with the next Component. |
public void animateLayout(int duration) | Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation |
public void animateLayoutAndWait(int duration) | Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation. |
public void animateLayoutFade(int duration, int startingOpacity) | Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation |
public void animateLayoutFadeAndWait(int duration, int startingOpacity) | Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation. |
public void animateHierarchy(int duration) | Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation |
public void animateHierarchyAndWait(int duration) | Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation. |
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 |
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. |
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. |
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. |
public Layout getLayout() | Returns the layout manager responsible for arranging this container. |
public void setLayout(Layout layout) | Sets the layout manager responsible for arranging this container |
public boolean isScrollable() | Indicates whether the component should/could scroll by default a component is not scrollable. |
public void setScrollable(boolean scrollable) | The equivalent of calling both setScrollableY and setScrollableX |
public void setRTL(boolean r) | Is the component a bidi RTL component |
public boolean isScrollableX() | Indicates whether the component should/could scroll on the X axis |
public void setScrollableX(boolean scrollableX) | Sets whether the component should/could scroll on the X axis |
public boolean isScrollableY() | Indicates whether the component should/could scroll on the Y axis |
public void setScrollableY(boolean scrollableY) | Sets whether the component should/could scroll on the Y axis |
public boolean isScrollVisible() | Indicate whether this component scroll is visible |
public void setScrollVisible(boolean scrollVisible) | Set whether this component scroll is visible |
public boolean isSmoothScrolling() | Indicates that scrolling through the component should work as an animation |
public void setSmoothScrolling(boolean smoothScrolling) | Indicates that scrolling through the component should work as an animation |
public int getScrollAnimationSpeed() | Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode |
public void setScrollAnimationSpeed(int animationSpeed) | Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode |
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) |
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) |
Inherited fields
From Component
DEFAULT_CURSOR, CROSSHAIR_CURSOR, TEXT_CURSOR, WAIT_CURSOR, SW_RESIZE_CURSOR, SE_RESIZE_CURSOR, NW_RESIZE_CURSOR, NE_RESIZE_CURSOR, N_RESIZE_CURSOR, S_RESIZE_CURSOR, W_RESIZE_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_Y, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_IMMEDIATELY_DRAG_XY, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET, BRB_OTHER, CENTER, TOP, LEFT, BOTTOM, RIGHT, BASELINE
Inherited methods
From Container
encloseIn, encloseIn, initLaf, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, replaceAndWait, replace, replaceAndWait, createReplaceTransition, isEnabled, setEnabled, cancelRepaints, flushReplace, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paintGlass, layoutContainer, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, contains, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, calcPreferredSize, paramString, getBottomGap, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayoutFadeAndWait, createAnimateLayoutFade, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator
From Component
setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, isDragRegion, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, repaint, repaint, registerForAnimation, deregisterFromAnimation, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, stopScrollMomentum, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, animate, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, setIsScrollVisible, startEditingAsync, isEditable, laidOut, deinitialize, initComponent, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip
Field details
DISPOSE_ON_CLOSE
public static final int DISPOSE_ON_CLOSE = 0HIDE_ON_CLOSE
public static final int HIDE_ON_CLOSE = 1DO_NOTHING_ON_CLOSE
public static final int DO_NOTHING_ON_CLOSE = 2#dispose() itself from a close listener.MODALITY_NONE
public static final int MODALITY_NONE = 0MODALITY_WINDOW
public static final int MODALITY_WINDOW = 1MODALITY_APPLICATION
public static final int MODALITY_APPLICATION = 2Constructor details
Window
public Window()FlowLayout.Window
public Window(Layout contentPaneLayout)Parameters
contentPaneLayoutLayout- the layout for the content pane
Window
public Window(String title)FlowLayout.Parameters
titleString- the window title
Window
public Window(String title, Layout contentPaneLayout)Parameters
titleString- the window title
contentPaneLayoutLayout- 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
asContainer
public Container asContainer()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
getContentPane
public Container getContentPane()Returns
getLayeredPane
public Container getLayeredPane()Returns
getLayeredPane
public Container getLayeredPane(Class c, boolean top)Parameters
cClass- the class owning the layer
topboolean- true to place the layer above the existing layers
Returns
getLayeredPane
public Container getLayeredPane(Class c, int zIndex)Parameters
cClass- the class owning the layer
zIndexint- the depth at which the layer should sit
Returns
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.
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.
Parameters
cClass- the class owning the layer
topboolean- true to place the layer above the existing layers
Returns
getGlassPane
public Painter getGlassPane()Returns
setGlassPane
public void setGlassPane(Painter glassPane)Parameters
glassPanePainter- the painter to install, or null to remove the current one
getTitle
public String getTitle()Returns
setTitle
public void setTitle(String title)Parameters
titleString- the title to display
addCommand
public void addCommand(Command cmd)Parameters
cmdCommand- the command to add
removeCommand
public void removeCommand(Command cmd)Parameters
cmdCommand- the command to remove
removeAllCommands
public void removeAllCommands()getCommandCount
public int getCommandCount()Returns
getCommand
public Command getCommand(int index)Parameters
indexint- the offset of the command
Returns
addCommandListener
public void addCommandListener(ActionListener l)Parameters
lActionListener- the listener to add
removeCommandListener
public void removeCommandListener(ActionListener l)Parameters
lActionListener- the listener to remove
isTopLevelShowing
public boolean isTopLevelShowing()Returns
dispatchCommand
public void dispatchCommand(Command cmd, ActionEvent ev)Command triggers it without knowing whether it
lives in a Form or a Window.Parameters
cmdCommand- the command to dispatch
evActionEvent- the event to dispatch
getAnimationManager
public AnimationManager getAnimationManager()registerAnimated
public void registerAnimated(Animation cmp)Parameters
cmpAnimation- the animation to register
deregisterAnimated
public void deregisterAnimated(Animation cmp)Parameters
cmpAnimation- the animation to remove
grabAnimationLock
public boolean grabAnimationLock()Returns
releaseAnimationLock
public void releaseAnimationLock()getFocused
public Component getFocused()Returns
setFocused
public void setFocused(Component focused)Parameters
focusedComponent- the component that should take focus
isCyclicFocus
public boolean isCyclicFocus()Returns
setCyclicFocus
public void setCyclicFocus(boolean cyclicFocus)Parameters
cyclicFocusboolean- true to make focus cyclic
isSingleFocusMode
public boolean isSingleFocusMode()Returns
getTabIterator
public Form.TabIterator getTabIterator(Component start)Parameters
startComponent- the component to start from
Returns
scrollComponentToVisible
public void scrollComponentToVisible(Component c)Parameters
cComponent- the component that will be scrolling for visibility
addKeyListener
public void addKeyListener(int keyCode, ActionListener listener)Parameters
keyCodeint- the key code to bind
listenerActionListener- the listener invoked for that key
removeKeyListener
public void removeKeyListener(int keyCode, ActionListener listener)Parameters
keyCodeint- the bound key code
listenerActionListener- the listener to remove
isEditing
public boolean isEditing()Returns
stopEditing
public void stopEditing(Runnable onFinish)Parameters
onFinishRunnable- Callback called when the editing is complete.
findCurrentlyEditingComponent
public Component findCurrentlyEditingComponent()Returns
getCurrentInputDevice
public VirtualInputDevice getCurrentInputDevice()Returns
setCurrentInputDevice
public void setCurrentInputDevice(VirtualInputDevice device)
throws ExceptionParameters
deviceVirtualInputDevice- the device to open, or null to close the current one
Throws
Exception- if the previously open device failed to close
getUIManager
public UIManager getUIManager()Returns
setUIManager
public void setUIManager(UIManager uiManager)Parameters
uiManagerUIManager- UIManager instance
getTintColor
public int getTintColor()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.
Note the window does not paint this itself, unlike Form. Its layered pane
repaints the whole window underneath whatever sits in the pane
(#getFormLayeredPane(java.lang.Class, boolean)), so a tint applied in
#paint(Graphics) would be composited once for the window and once more for
that backdrop, and read visibly darker than the same tint on a form. What
covers the window paints the tint instead, exactly once.
Returns
refreshTheme
public void refreshTheme(boolean merge)Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!
A window caches the tint it took from the look and feel, so a theme change has to drop it or every later overlay keeps painting the old theme’s scrim.
Parameters
mergeboolean- indicates if the current styles should be merged with the new styles
setTintColor
public void setTintColor(int tintColor)Parameters
tintColorint- the tint colour, alpha in the high byte
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.
A desktop window has no notch or rounded corner to avoid, so the safe area is the whole window.
Returns
getInvisibleAreaUnderVKB
public int getInvisibleAreaUnderVKB()Returns the area of this component that is currently hidden by the virtual keyboard.
Always zero: a desktop window has no virtual keyboard overlaying it.
Returns
The height of the area under the virtual keyboard in pixels The part of this component the virtual keyboard is covering, which the scroll range has to include or whatever is under the keyboard can never be brought into view.
Package private rather than private because the wheel scroll in Display needs the
same number the drag path uses: a wheel clamps the position itself, and clamping to
a range that stops at the keyboard is how a field hidden behind it becomes
unreachable with a trackpad.
getDragRegionStatus
public int getDragRegionStatus(int x, int y)Parameters
xint- x location for the touch
yint- y location for the touch
Returns
isEnableCursors
public boolean isEnableCursors()Returns
setEnableCursors
public void setEnableCursors(boolean e)Parameters
eboolean- true to enable cursors
getTextSelection
public TextSelection getTextSelection()Returns
setResizable
public void setResizable(boolean resizable)Parameters
resizableboolean- true to allow resizing
isResizable
public boolean isResizable()Returns
setDecorated
public void setDecorated(boolean decorated)Sets whether the platform draws a title bar and border for this window.
An undecorated window draws no chrome of its own either, and
#getDragRegionStatus(int, int) refuses to drag it, so the application has to
supply both. A Toolbar is not the way to do that: it is installed through
Form#setToolbar(Toolbar) and is bound to a form throughout, so it cannot be
put on a window.
Parameters
decoratedboolean- true for native decorations
isDecorated
public boolean isDecorated()Returns
setAlwaysOnTop
public void setAlwaysOnTop(boolean alwaysOnTop)Parameters
alwaysOnTopboolean- true to float the window
isAlwaysOnTop
public boolean isAlwaysOnTop()Returns
setUtilityWindow
public void setUtilityWindow(boolean utility)Parameters
utilityboolean- true for a utility window
isUtilityWindow
public boolean isUtilityWindow()Returns
setWindowIcon
public void setWindowIcon(Image icon)Parameters
iconImage- the icon to display
getWindowIcon
public Image getWindowIcon()Returns
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
setWindowContentSize
public void setWindowContentSize(int width, int height)Sizes this window so its Codename One drawable area is the given size, rather than its native frame.
#setWindowSize(int, int) asks the platform for a frame of that size. On a
decorated window the title bar and borders sit outside the surface Codename One
paints into, so the drawable comes back smaller – and content sized to fit is
clipped along the bottom by exactly the height of the title bar. This asks for
the drawable size instead and lets the window work out its own chrome.
The correction is applied once, after the native window exists, and only when the platform actually disagrees. A port whose chrome varies with the size it is given cannot make this oscillate.
Parameters
widthint- the drawable width in pixels
heightint- the drawable height in pixels
getWorkAreaInPixels
public Rectangle getWorkAreaInPixels()The usable area of this window’s display, in the device pixels a layout uses.
Monitor#getWorkArea() is in desktop coordinates, which count pixels only where
the platform’s own coordinates do. Compared raw against a preferred size, the
usable width on a display at twice the scale reads as half what it is – so a
dialog capped at nine tenths of it was really held to about 45%.
Returns
setWindowBounds
public void setWindowBounds(Rectangle r)setWindowSize
public void setWindowSize(int width, int height)Parameters
widthint- the new width
heightint- the new height
setWindowLocation
public void setWindowLocation(int x, int y)Parameters
xint- the new x position in desktop coordinates
yint- the new y position in desktop coordinates
setMinimumWindowSize
public void setMinimumWindowSize(Dimension d)Parameters
dDimension- the minimum size
getMinimumWindowSize
public Dimension getMinimumWindowSize()Returns
centerOnDesktop
public void centerOnDesktop()centerOn
public void centerOn(TopLevelContainer other)Parameters
otherTopLevelContainer- the top level to centre over
minimize
public void minimize()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()requestWindowFocus
public void requestWindowFocus()isWindowFocused
public boolean isWindowFocused()Returns
getMonitor
public Monitor getMonitor()Returns
getDensity
public int getDensity()Display reports.Returns
getScale
public double getScale()Returns
show
public void show()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)Parameters
typeint- one of
#MODALITY_NONE,#MODALITY_WINDOWor#MODALITY_APPLICATION
getModalityType
public int getModalityType()Returns
hide
public void hide()isWindowShowing
public boolean isWindowShowing()Returns
dispose
public void dispose()isWindowDisposed
public boolean isWindowDisposed()Returns
#dispose() has runhasPaintedOnce
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
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
setCloseOperation
public void setCloseOperation(int op)Parameters
opint- one of
#DISPOSE_ON_CLOSE,#HIDE_ON_CLOSEor#DO_NOTHING_ON_CLOSE
getCloseOperation
public int getCloseOperation()Returns
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
ownerTopLevelContainer- the owning top level
getOwnerWindow
public TopLevelContainer getOwnerWindow()Returns
addShowListener
public void addShowListener(ActionListener l)Parameters
lActionListener- the listener to add
removeShowListener
public void removeShowListener(ActionListener l)Parameters
lActionListener- the listener to remove
addSizeChangedListener
public void addSizeChangedListener(ActionListener l)Parameters
lActionListener- the listener to add
removeSizeChangedListener
public void removeSizeChangedListener(ActionListener l)Parameters
lActionListener- the listener to remove
addCloseListener
public void addCloseListener(ActionListener l)Parameters
lActionListener- the listener to add
removeCloseListener
public void removeCloseListener(ActionListener l)Parameters
lActionListener- the listener to remove
addWindowListener
public void addWindowListener(ActionListener l)Parameters
lActionListener- the listener to add
removeWindowListener
public void removeWindowListener(ActionListener l)Parameters
lActionListener- the listener to remove
paint
public void paint(Graphics g)Parameters
gGraphics- the component graphics
getSideGap
public int getSideGap()Returns
pointerPressed
public void pointerPressed(int x, int y)If this Component is focused, the pointer pressed event will call this method
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.
Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
pointerDragged
public void pointerDragged(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
pointerDragged
public void pointerDragged(int[] x, int[] y)If this Component is focused, the pointer dragged event will call this method
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.
Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
pointerReleased
public void pointerReleased(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
longKeyPress
protected void longKeyPress(int keyCode)If this Component is focused this method is invoked when the user presses and holds the 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.
Parameters
keyCodeint- the key code value to indicate a physical key.
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.
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.
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.
Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
pointerHoverReleased
public void pointerHoverReleased(int[] x, int[] y)Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
pointerHoverPressed
public void pointerHoverPressed(int[] x, int[] y)Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
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.
Parameters
cC- the component awaiting a release
Returns
Container
Records a component that is waiting for a pointer release, so the top level can
release it if the gesture ends somewhere else.removeComponentAwaitingRelease
public <C extends Component> void removeComponentAwaitingRelease(C c)Parameters
cC- the component to stop tracking
clearComponentsAwaitingRelease
public void clearComponentsAwaitingRelease()keyPressed
public void keyPressed(int keyCode)If this Component is focused, the key pressed event will call this method
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.
Parameters
keyCodeint- the key code value to indicate a physical key.
keyReleased
public void keyReleased(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
keyRepeated
public void keyRepeated(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
addComponent
public void addComponent(Component cmp)Adds a Component to the Container
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.
Parameters
cmpComponent- the component to be added
addComponent
public void addComponent(Object constraints, Component cmp)Parameters
constraintsObject- 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”…
cmpComponent- component to add
addComponent
public void addComponent(int index, Component cmp)This method adds the Component at a specific index location in the Container Components array.
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.
Parameters
indexint- location to insert the Component
cmpComponent- the Component to add
Throws
ArrayIndexOutOfBoundsException- if index is out of bounds
IllegalArgumentException- if Component is already contained or the cmp is a Form Component
addComponent
public void addComponent(int index, Object constraints, Component cmp)Parameters
indexint- location to insert the Component
constraintsObject- 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”…
cmpComponent- component to add
removeComponent
public void removeComponent(Component cmp)Parameters
cmpComponent- the removed component
removeAll
public void removeAll()getComponentIndex
public int getComponentIndex(Component cmp)Parameters
cmpComponent- the component to search for
Returns
setContent
public void setContent(Component content, Transition t)Replaces this window’s content, animating the change.
The window analogue of showing another Form with a transition, and the reason
a Form transition into or out of a window is not a thing: a transition paints
the two screens into one Graphics covering one surface, and two operating
system windows are composited by the window server, on monitors that may not
even share a scale factor. There is no shared context to draw an in between
frame into. Moving between screens inside one window is an ordinary
transition, and this is it.
Parameters
contentComponent- the new content
tTransition- the transition to animate with, or null to swap immediately
replace
public void replace(Component current, Component next, Transition t)Parameters
currentComponent- a Component to remove from the Container
nextComponent- a Component that replaces the current Component
tTransition- a Transition between the add and removal of the Components a Transition can be null
replaceAndWait
public void replaceAndWait(Component current, Component next, Transition t)Parameters
currentComponent- a Component to remove from the Container
nextComponent- a Component that replaces the current Component
tTransition- a Transition between the add and removal of the Components a Transition can be null
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
durationint- the duration in milliseconds for the animation
animateLayoutAndWait
public void animateLayoutAndWait(int duration)Parameters
durationint- the duration in milliseconds for the animation
animateLayoutFade
public void animateLayoutFade(int duration, int startingOpacity)Parameters
durationint- the duration in milliseconds for the animation
startingOpacityint- the initial opacity to give to the animated components
animateLayoutFadeAndWait
public void animateLayoutFadeAndWait(int duration, int startingOpacity)Parameters
durationint- the duration in milliseconds for the animation
startingOpacityint- the initial opacity to give to the animated components
animateHierarchy
public void animateHierarchy(int duration)Parameters
durationint- the duration in milliseconds for the animation
animateHierarchyAndWait
public void animateHierarchyAndWait(int duration)Parameters
durationint- the duration in milliseconds for the animation
animateHierarchyFade
public void animateHierarchyFade(int duration, int startingOpacity)Parameters
durationint- the duration in milliseconds for the animation
startingOpacityint- the initial opacity to give to the animated components
animateHierarchyFadeAndWait
public void animateHierarchyFadeAndWait(int duration, int startingOpacity)Parameters
durationint- the duration in milliseconds for the animation
startingOpacityint- the initial opacity to give to the animated components
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
durationint- the duration of the animation
opacityint- the opacity to which the layout will reach, allows fading out the components
callbackRunnable- if not null will be invoked when unlayouting is complete
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
durationint- the duration of the animation
opacityint- the opacity to which the layout will reach, allows fading out the components
getLayout
public Layout getLayout()Returns
setLayout
public void setLayout(Layout layout)Parameters
layoutLayout- the specified layout manager
isScrollable
public boolean isScrollable()Returns
setScrollable
public void setScrollable(boolean scrollable)Parameters
scrollableboolean- whether the component should/could scroll on the X and Y axis
setRTL
public void setRTL(boolean r)Is the component a bidi RTL component
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.
Parameters
rboolean- true if the component should work in a right to left mode
isScrollableX
public boolean isScrollableX()Returns
setScrollableX
public void setScrollableX(boolean scrollableX)Parameters
scrollableXboolean- whether the component should/could scroll on the X axis
isScrollableY
public boolean isScrollableY()Returns
setScrollableY
public void setScrollableY(boolean scrollableY)Parameters
scrollableYboolean- whether the component should/could scroll on the Y axis
isScrollVisible
public boolean isScrollVisible()Returns
setScrollVisible
public void setScrollVisible(boolean scrollVisible)Parameters
scrollVisibleboolean- Indicate whether this component scroll is visible
isSmoothScrolling
public boolean isSmoothScrolling()Returns
setSmoothScrolling
public void setSmoothScrolling(boolean smoothScrolling)Parameters
smoothScrollingboolean- indicates if a component uses smooth scrolling
getScrollAnimationSpeed
public int getScrollAnimationSpeed()Returns
setScrollAnimationSpeed
public void setScrollAnimationSpeed(int animationSpeed)Parameters
animationSpeedint- scroll animation speed in milliseconds
isAlwaysTensile
public boolean isAlwaysTensile()Returns
setAlwaysTensile
public void setAlwaysTensile(boolean alwaysTensile)Parameters
alwaysTensileboolean- the alwaysTensile to set