Class Window
- All Implemented Interfaces:
Animation, Editable, StyleListener, TopLevelContainer, Iterable<Component>
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
FieldsModifier and TypeFieldDescriptionstatic final intClosing the window disposes it and releases the native window.static final intClosing the window does nothing, leaving the application to call#dispose()itself from a close listener.static final intClosing the window hides it, leaving it able to be shown again.static final intThe window blocks input to every other window and to the main form.static final intThe window does not block input to any other window.static final intThe 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
ConstructorsConstructorDescriptionWindow()Creates a window whose content is laid out with aFlowLayout.Creates a window with the given content layout.Creates a window with the given title, laid out with aFlowLayout.Creates a window with the given title and content layout. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener notified when the user tries to close this window.voidaddCommand(Command cmd) Adds a command to this top level.voidAdds a listener notified when a command is activated.voidaddComponent(int index, Component cmp) This method adds the Component at a specific index location in the Container Components array.voidaddComponent(int index, Object constraints, Component cmp) Adds a Component to the ContainervoidaddComponent(Component cmp) Adds a Component to the ContainervoidaddComponent(Object constraints, Component cmp) Adds a Component to the Container<C extends Component>
voidReturns this top level as aContainer.voidaddKeyListener(int keyCode, ActionListener listener) Adds a key binding scoped to this top level.voidAdds a listener notified whenever this top level is shown.voidAdds a listener notified whenever this top level changes size.voidAdds a listener notified when this window is shown, hidden, moved or resized.voidanimateHierarchy(int duration) Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animationvoidanimateHierarchyAndWait(int duration) Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation.voidanimateHierarchyFade(int duration, int startingOpacity) Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animationvoidanimateHierarchyFadeAndWait(int duration, int startingOpacity) Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation.voidanimateLayout(int duration) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animationvoidanimateLayoutAndWait(int duration) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation.voidanimateLayoutFade(int duration, int startingOpacity) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animationvoidanimateLayoutFadeAndWait(int duration, int startingOpacity) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation.voidanimateUnlayout(int duration, int opacity, Runnable callback) This method is the exact reverse of animateLayout, when completed it leaves the container in an invalid state.voidanimateUnlayoutAndWait(int duration, int opacity) This method is the exact reverse of animateLayoutAndWait, when completed it leaves the container in an invalid state.capture()Captures this window's current contents.voidcenterOn(TopLevelContainer other) Centres this window over another top level.voidCentres this window on the work area of the monitor it sits on, so it does not land under the task bar or dock.voidDrops every component waiting for a pointer release, used when a gesture is taken over by something else -- a pull to refresh, for instance.voidRemoves a previously registered animation.voiddispatchCommand(Command cmd, ActionEvent ev) Dispatches a command to this top level's command handling, which is how a component that holds aCommandtriggers it without knowing whether it lives in aFormor aWindow.voiddispose()Destroys this window and releases the native window behind it.Returns the component currently being edited.Returns the animation manager of the parent form or null if this component isn't currently associated with a formintReturns what happens when the user closes this window.getCommand(int index) Returns the command at the given offset.intReturns the number of commands.intReturns the Component index in the ContainerReturns the container holding the application content of this top level.Returns the virtual input device currently open for this top level.intReturns the density of the monitor this window sits on, which on a mixed resolution desktop is not necessarily the densityDisplayreports.intgetDragRegionStatus(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.Returns the component currently owning focus.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.Returns the painter drawn above everything else in this top level.intReturns the height hidden behind the virtual keyboard, which is zero on a platform without one.Returns the layered pane covering the content area, creating it if needed.getLayeredPane(Class c, boolean top) Returns the layer belonging to the given class within the content-area layered pane, creating it if needed.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.Returns the layout manager responsible for arranging this container.Returns the smallest size the user may resize this window to.intReturns how this window blocks input to the others.Returns the monitor this window currently sits on.Returns the top level that owns this window.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.doublegetScale()Returns the backing scale of the monitor this window sits on.intScroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation modeintReturns the gap to be left for the side scrollbar on the Y axis.getTabIterator(Component start) Returns an iterator walking the components in traversal order.Returns the text selection support for this top level.getTitle()Returns the title text.Returns the area reserved for the title and its surrounding chrome.Returns the toolbar installed in this top level.Returns the top level container this component currently belongs to, which is either theFormfilling the main surface or theWindowof a native desktop window, or null when this component is not attached to one.This method should be used by the Component to retrieve the correct UIManager to work withReturns this window's bounds in desktop coordinates, including any native chrome.Returns the icon the platform shows for this window.intReturns the framework assigned id of this window.booleanTakes the animation lock, blocking until no animation is in progress.booleanIndicates 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.voidhide()Hides this window without destroying it, so it can be shown again.booleanIndicates whether this window floats above the others.booleanEnable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)booleanReturns true when focus traversal wraps around at the edges.booleanIndicates whether the platform draws this window's chrome.booleanChecks if the component is currently being edited.booleanReturns true when components may change the mouse cursor.booleanIndicates whether the user may resize this window.booleanIndicates whether the component should/could scroll by default a component is not scrollable.booleanIndicates whether the component should/could scroll on the X axisbooleanIndicates whether the component should/could scroll on the Y axisbooleanIndicate whether this component scroll is visiblebooleanReturns true when only one component in this top level can take focus.booleanIndicates that scrolling through the component should work as an animationbooleanIndicates whether this is a utility window.booleanIndicates whether this window has been disposed.booleanIndicates whether this window currently holds keyboard focus.booleanIndicates whether this window is currently mapped on screen.voidkeyPressed(int keyCode) If this Component is focused, the key pressed event will call this methodvoidkeyReleased(int keyCode) If this Component is focused, the key released event will call this methodvoidkeyRepeated(int keyCode) If this Component is focused, the key repeat event will call this method.protected voidlongKeyPress(int keyCode) If this Component is focused this method is invoked when the user presses and holds the keyvoidlongPointerPress(int x, int y) If this Component is focused this method is invoked when the user presses and holds the pointer on the Componentvoidminimize()Minimizes this window.voidThis 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.voidpointerDragged(int[] x, int[] y) If this Component is focused, the pointer dragged event will call this methodvoidpointerDragged(int x, int y) If this Component is focused, the pointer dragged event will call this methodvoidpointerHover(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerHoverPressed(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerHoverReleased(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerPressed(int x, int y) If this Component is focused, the pointer pressed event will call this methodvoidpointerReleased(int x, int y) If this Component is focused, the pointer released event will call this methodvoidRegisters an animation that is invoked on every frame of this top level.voidReleases a previously taken animation lock.voidremove all Components from container, notice that removed component might still have a pending repaint in the queue that won't be removed.voidRemoves every command from this top level.voidRemoves a previously added close listener.voidremoveCommand(Command cmd) Removes a command from this top level.voidRemoves a previously added command listener.voidremoveComponent(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>
voidStops tracking a component that was waiting for a pointer release.voidremoveKeyListener(int keyCode, ActionListener listener) Removes a previously added key binding.voidRemoves a previously added show listener.voidRemoves a previously added size changed listener.voidRemoves a previously added window listener.voidreplace(Component current, Component next, Transition t) This method replaces the current Component with the next Component.voidreplaceAndWait(Component current, Component next, Transition t) This method replaces the current Component with the next Component.voidRaises this window and gives it keyboard focus.voidrestore()Restores this window from a minimized state.voidMakes sure the component is visible in the scroll if this container is scrollablevoidsetAlwaysOnTop(boolean alwaysOnTop) Keeps this window above the application's other windows.voidsetAlwaysTensile(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)voidsetCloseOperation(int op) Sets what happens when the user closes this window through the platform's own close control.voidOpens a virtual input device, closing whichever one was open before it.voidsetCyclicFocus(boolean cyclicFocus) Sets whether focus traversal wraps around at the edges.voidsetDecorated(boolean decorated) Sets whether the platform draws a title bar and border for this window.voidsetEnableCursors(boolean e) Sets whether components may change the mouse cursor.voidsetFocused(Component focused) Moves focus to the given component.voidsetGlassPane(Painter glassPane) Sets the painter drawn above everything else in this top level.voidSets the layout manager responsible for arranging this containervoidSets the smallest size the user may resize this window to.voidsetModalityType(int type) Sets how this window blocks input to the others.voidsetOwnerWindow(TopLevelContainer owner) Sets the top level that owns this window.voidsetResizable(boolean resizable) Sets whether the user may resize this window.voidsetRTL(boolean r) Is the component a bidi RTL componentvoidsetScrollable(boolean scrollable) The equivalent of calling both setScrollableY and setScrollableXvoidsetScrollableX(boolean scrollableX) Sets whether the component should/could scroll on the X axisvoidsetScrollableY(boolean scrollableY) Sets whether the component should/could scroll on the Y axisvoidsetScrollAnimationSpeed(int animationSpeed) Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation modevoidsetScrollVisible(boolean scrollVisible) Set whether this component scroll is visiblevoidsetSmoothScrolling(boolean smoothScrolling) Indicates that scrolling through the component should work as an animationvoidSets the title text.voidsetToolbar(Toolbar toolbar) Installs a toolbar in this top level.voidsetUIManager(UIManager uiManager) Allows replacing the UIManager in a component hierarchy to update the look and feel only to a specific hierarchyvoidsetUtilityWindow(boolean utility) Marks this window as a palette or tool window, which the platform typically keeps out of the task bar.voidMoves and resizes this window.voidsetWindowIcon(Image icon) Sets the icon the platform shows for this window.voidsetWindowLocation(int x, int y) Moves this window, leaving its size alone.voidsetWindowSize(int width, int height) Resizes this window, leaving its position alone.voidshow()Shows this window, creating the native window the first time it is called.voidShows this window and blocks the calling code until it is disposed.voidstopEditing(Runnable onFinish) Stops the editing process.voidToggles 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, updateTabIndicesMethods 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, 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, 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
-
Field Details
-
DISPOSE_ON_CLOSE
public static final int DISPOSE_ON_CLOSEClosing the window disposes it and releases the native window. The default.- See Also:
-
HIDE_ON_CLOSE
public static final int HIDE_ON_CLOSEClosing the window hides it, leaving it able to be shown again.- See Also:
-
DO_NOTHING_ON_CLOSE
public static final int DO_NOTHING_ON_CLOSEClosing the window does nothing, leaving the application to call#dispose()itself from a close listener.- See Also:
-
MODALITY_NONE
public static final int MODALITY_NONEThe window does not block input to any other window.- See Also:
-
MODALITY_WINDOW
public static final int MODALITY_WINDOWThe window blocks input to the window that owns it.- See Also:
-
MODALITY_APPLICATION
public static final int MODALITY_APPLICATIONThe window blocks input to every other window and to the main form.- See Also:
-
-
Constructor Details
-
Window
public Window()Creates a window whose content is laid out with aFlowLayout. -
Window
Creates a window with the given content layout.
Parameters
contentPaneLayout: the layout for the content pane
-
Window
Creates a window with the given title, laid out with a
FlowLayout.Parameters
title: the window title
-
Window
-
-
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
- Specified by:
asContainerin interfaceTopLevelContainer
-
getTopLevelContainer
Returns the top level container this component currently belongs to, which is either the
Formfilling the main surface or theWindowof 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 desktopWindow.getComponentForm()keeps its original meaning and returns null for a component hosted in aWindow, because aWindowis not aForm.Returns
the enclosing top level container, or null when detached
See also
- #getComponentForm()
- Overrides:
getTopLevelContainerin classComponent
-
getContentPane
Returns the container holding the application content of this top level.
Returns
the content pane
- Specified by:
getContentPanein interfaceTopLevelContainer
-
getTitleArea
Returns the area reserved for the title and its surrounding chrome.
Returns
the title area container
- Specified by:
getTitleAreain interfaceTopLevelContainer
-
getLayeredPane
Returns the layered pane covering the content area, creating it if needed.
Returns
the layered pane
- Specified by:
getLayeredPanein interfaceTopLevelContainer
-
getLayeredPane
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:
getLayeredPanein interfaceTopLevelContainer
-
-
getLayeredPane
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:
getLayeredPanein interfaceTopLevelContainer
-
-
getFormLayeredPane
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,InteractionDialogandToastBarattach through this method, and renaming it for windows would fork them.- Specified by:
getFormLayeredPanein interfaceTopLevelContainer
-
-
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:
getGlassPanein interfaceTopLevelContainer
-
setGlassPane
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:
setGlassPanein interfaceTopLevelContainer
-
getTitle
Returns the title text.
Returns
the title
- Specified by:
getTitlein interfaceTopLevelContainer
-
setTitle
Sets the title text.
Parameters
title: the title to display
Sets both the Codename One title component and the native window title.
- Specified by:
setTitlein interfaceTopLevelContainer
-
getToolbar
Returns the toolbar installed in this top level.
Returns
the toolbar, or null when none is installed
- Specified by:
getToolbarin interfaceTopLevelContainer
-
setToolbar
Installs a toolbar in this top level.
Parameters
toolbar: the toolbar to install
- Specified by:
setToolbarin interfaceTopLevelContainer
-
addCommand
Adds a command to this top level.
Parameters
cmd: the command to add
- Specified by:
addCommandin interfaceTopLevelContainer
-
removeCommand
Removes a command from this top level.
Parameters
cmd: the command to remove
- Specified by:
removeCommandin interfaceTopLevelContainer
-
removeAllCommands
public void removeAllCommands()Removes every command from this top level.- Specified by:
removeAllCommandsin interfaceTopLevelContainer
-
getCommandCount
public int getCommandCount()Returns the number of commands.
Returns
the command count
- Specified by:
getCommandCountin interfaceTopLevelContainer
-
getCommand
Returns the command at the given offset.
Parameters
index: the offset of the command
Returns
the command at that offset
- Specified by:
getCommandin interfaceTopLevelContainer
-
addCommandListener
Adds a listener notified when a command is activated.
Parameters
l: the listener to add
- Specified by:
addCommandListenerin interfaceTopLevelContainer
-
removeCommandListener
Removes a previously added command listener.
Parameters
l: the listener to remove
- Specified by:
removeCommandListenerin interfaceTopLevelContainer
-
dispatchCommand
Description copied from interface:TopLevelContainerDispatches a command to this top level's command handling, which is how a component that holds a
Commandtriggers it without knowing whether it lives in aFormor aWindow.Parameters
-
cmd: the command to dispatch -
ev: the event to dispatch
- Specified by:
dispatchCommandin interfaceTopLevelContainer
-
-
getAnimationManager
Returns the animation manager of the parent form or null if this component isn't currently associated with a form
Returns
the animation manager instance
- Specified by:
getAnimationManagerin interfaceTopLevelContainer- Overrides:
getAnimationManagerin classComponent
-
registerAnimated
Registers an animation that is invoked on every frame of this top level.
Parameters
cmp: the animation to register
- Specified by:
registerAnimatedin interfaceTopLevelContainer
-
deregisterAnimated
Removes a previously registered animation.
Parameters
cmp: the animation to remove
- Specified by:
deregisterAnimatedin interfaceTopLevelContainer
-
grabAnimationLock
public boolean grabAnimationLock()Takes the animation lock, blocking until no animation is in progress.
Returns
true if the lock was taken
- Specified by:
grabAnimationLockin interfaceTopLevelContainer
-
releaseAnimationLock
public void releaseAnimationLock()Releases a previously taken animation lock.- Specified by:
releaseAnimationLockin interfaceTopLevelContainer
-
getFocused
Returns the component currently owning focus.
Returns
the focus owner, or null when nothing is focused
- Specified by:
getFocusedin interfaceTopLevelContainer
-
setFocused
Moves focus to the given component.
Parameters
focused: the component that should take focus
- Specified by:
setFocusedin interfaceTopLevelContainer
-
isCyclicFocus
public boolean isCyclicFocus()Returns true when focus traversal wraps around at the edges.
Returns
true if focus is cyclic
- Specified by:
isCyclicFocusin interfaceTopLevelContainer
-
setCyclicFocus
public void setCyclicFocus(boolean cyclicFocus) Sets whether focus traversal wraps around at the edges.
Parameters
cyclicFocus: true to make focus cyclic
- Specified by:
setCyclicFocusin interfaceTopLevelContainer
-
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:
isSingleFocusModein interfaceTopLevelContainer
-
getTabIterator
Returns an iterator walking the components in traversal order.
Parameters
start: the component to start from
Returns
the traversal iterator
- Specified by:
getTabIteratorin interfaceTopLevelContainer
-
scrollComponentToVisible
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:
scrollComponentToVisiblein interfaceTopLevelContainer- Overrides:
scrollComponentToVisiblein classContainer
-
addKeyListener
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:
addKeyListenerin interfaceTopLevelContainer
-
-
removeKeyListener
Removes a previously added key binding.
Parameters
-
keyCode: the bound key code -
listener: the listener to remove
- Specified by:
removeKeyListenerin interfaceTopLevelContainer
-
-
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)
-
-
stopEditing
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:
stopEditingin interfaceEditable- Specified by:
stopEditingin interfaceTopLevelContainer- Overrides:
stopEditingin classComponent
-
findCurrentlyEditingComponent
Returns the component currently being edited.
Returns
the edited component, or null when nothing is being edited
- Specified by:
findCurrentlyEditingComponentin interfaceTopLevelContainer
-
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:
getCurrentInputDevicein interfaceTopLevelContainer
-
setCurrentInputDevice
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:
setCurrentInputDevicein interfaceTopLevelContainer- Throws:
Exception
-
getUIManager
This method should be used by the Component to retrieve the correct UIManager to work with
Returns
a UIManager instance
- Specified by:
getUIManagerin interfaceTopLevelContainer- Overrides:
getUIManagerin classContainer
-
setUIManager
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:
setUIManagerin interfaceTopLevelContainer- Overrides:
setUIManagerin classContainer
-
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:
getSafeAreain interfaceTopLevelContainer
-
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:
getInvisibleAreaUnderVKBin interfaceTopLevelContainer
-
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:
getDragRegionStatusin interfaceTopLevelContainer- Overrides:
getDragRegionStatusin classComponent
-
-
isEnableCursors
public boolean isEnableCursors()Returns true when components may change the mouse cursor.
Returns
true if cursors are enabled
- Specified by:
isEnableCursorsin interfaceTopLevelContainer
-
setEnableCursors
public void setEnableCursors(boolean e) Sets whether components may change the mouse cursor.
Parameters
e: true to enable cursors
- Specified by:
setEnableCursorsin interfaceTopLevelContainer
-
getTextSelection
Returns the text selection support for this top level.
Returns
the text selection
- Specified by:
getTextSelectionin interfaceTopLevelContainer
-
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
Toolbaris 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
Sets the icon the platform shows for this window.
Parameters
icon: the icon to display
-
getWindowIcon
Returns the icon the platform shows for this window.
Returns
the window icon, or null when none was set
-
getWindowBounds
Returns this window's bounds in desktop coordinates, including any native chrome.
This is a different coordinate space from
Component#getWidth()andComponent#getHeight(), which report the Codename One content size.Returns
the native window bounds
-
setWindowBounds
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
Sets the smallest size the user may resize this window to.
Parameters
d: the minimum size
-
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
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
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
Displayreports.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:
showin interfaceTopLevelContainer
-
showModal
public void showModal()Shows this window and blocks the calling code until it is disposed.
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_WINDOWor#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
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_CLOSEor#DO_NOTHING_ON_CLOSE
-
getCloseOperation
public int getCloseOperation()Returns what happens when the user closes this window.
Returns
the close operation
-
setOwnerWindow
Sets the top level that owns this window. An owned window stays above its owner and is disposed with it.
The name avoids
setOwner, whichComponentalready uses for an unrelated hit testing mechanism.Parameters
owner: the owning top level
-
getOwnerWindow
Returns the top level that owns this window.
Returns
the owner, or null when the window is unowned
-
addShowListener
Adds a listener notified whenever this top level is shown.
Parameters
l: the listener to add
- Specified by:
addShowListenerin interfaceTopLevelContainer
-
removeShowListener
Removes a previously added show listener.
Parameters
l: the listener to remove
- Specified by:
removeShowListenerin interfaceTopLevelContainer
-
addSizeChangedListener
Adds a listener notified whenever this top level changes size.
Parameters
l: the listener to add
- Specified by:
addSizeChangedListenerin interfaceTopLevelContainer
-
removeSizeChangedListener
Removes a previously added size changed listener.
Parameters
l: the listener to remove
- Specified by:
removeSizeChangedListenerin interfaceTopLevelContainer
-
addCloseListener
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
Removes a previously added close listener.
Parameters
l: the listener to remove
-
addWindowListener
Adds a listener notified when this window is shown, hidden, moved or resized.
Parameters
l: the listener to add
-
removeWindowListener
Removes a previously added window listener.
Parameters
l: the listener to remove
-
paint
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
-
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:
getSideGapin classContainer
-
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
Containerhas no hit testing of its own --Formdoes that work itself -- so aWindowhas to as well, or a press would never reach the component under it. This is the same walkFormperforms, without the menu bar special case a window has no equivalent of.- Overrides:
pointerPressedin classContainer
-
-
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:
pointerDraggedin classComponent
-
-
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 itspinchcallbacks.- Overrides:
pointerDraggedin classComponent
-
-
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:
pointerReleasedin classComponent
-
-
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:Displaydispatches 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:
longKeyPressin classComponent
-
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:
longPointerPressin classComponent
-
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:
pointerHoverin classComponent
-
-
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:
pointerHoverReleasedin classComponent
-
-
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:
pointerHoverPressedin classComponent
-
-
addComponentAwaitingRelease
Returns this top level as a
Container.A Java interface cannot extend a class, so without this a
TopLevelContainerreference could not be handed to anything expecting aComponent.Returns
this instance, as a
ContainerRecords 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:
addComponentAwaitingReleasein interfaceTopLevelContainer
-
removeComponentAwaitingRelease
Stops tracking a component that was waiting for a pointer release.
Parameters
c: the component to stop tracking
- Specified by:
removeComponentAwaitingReleasein interfaceTopLevelContainer
-
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:
clearComponentsAwaitingReleasein interfaceTopLevelContainer
-
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
Formdoes. InheritingContainer'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:
keyPressedin classContainer
-
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:
keyReleasedin classContainer
-
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:
keyRepeatedin classComponent
-
addComponent
Adds a Component to the Container
Parameters
cmp: the component to be added
Adds to the content pane, mirroring
Form, sowindow.add(cmp)meanswindow.getContentPane().add(cmp). Container's add() is final and routes through here, so overriding addComponent covers both.- Overrides:
addComponentin classContainer
-
addComponent
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:
addComponentin classContainer
-
-
addComponent
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:
addComponentin classContainer
-
-
addComponent
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:
addComponentin classContainer
-
-
removeComponent
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:
removeComponentin classContainer
-
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. -
getComponentIndex
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:
getComponentIndexin classContainer
-
replace
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
-
-
replaceAndWait
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:
replaceAndWaitin classContainer
-
-
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:
animateLayoutin classContainer
-
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:
animateLayoutAndWaitin classContainer
-
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:
animateLayoutFadein classContainer
-
-
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:
animateLayoutFadeAndWaitin classContainer
-
-
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:
animateHierarchyin classContainer
-
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:
animateHierarchyAndWaitin classContainer
-
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:
animateHierarchyFadein classContainer
-
-
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:
animateHierarchyFadeAndWaitin classContainer
-
-
animateUnlayout
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:
animateUnlayoutin classContainer
-
-
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:
animateUnlayoutAndWaitin classContainer
-
-
getLayout
-
setLayout
-
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:
isScrollablein classComponent
-
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:
setScrollablein classContainer
-
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. -
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:
isScrollableXin classContainer
-
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:
setScrollableXin classContainer
-
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:
isScrollableYin classContainer
-
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:
setScrollableYin classContainer
-
isScrollVisible
public boolean isScrollVisible()Indicate whether this component scroll is visible
Returns
true is this component scroll is visible; otherwise false
- Overrides:
isScrollVisiblein classComponent
-
setScrollVisible
public void setScrollVisible(boolean scrollVisible) Set whether this component scroll is visible
Parameters
isScrollVisible: Indicate whether this component scroll is visible
- Overrides:
setScrollVisiblein classComponent
-
isSmoothScrolling
public boolean isSmoothScrolling()Indicates that scrolling through the component should work as an animation
Returns
whether this component use smooth scrolling
- Overrides:
isSmoothScrollingin classComponent
-
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:
setSmoothScrollingin classComponent
-
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:
getScrollAnimationSpeedin classComponent
-
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:
setScrollAnimationSpeedin classComponent
-
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:
isAlwaysTensilein classComponent
-
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:
setAlwaysTensilein classComponent
-