public class Form
ImplementsAnimation, Editable, Iterable<Component>, StyleListener, TopLevelContainer
Known subtypesDialog
Top level component that serves as the root for the UI, this Container
subclass works in concert with the Toolbar to create menus. By default a
forms main content area (the content pane) is scrollable on the Y axis and has a com.codename1.ui.layouts.FlowLayout as is the default.
Form contains a title bar area which in newer application is replaced by the Toolbar.
Calling #add(com.codename1.ui.Component) or all similar methods on the Form
delegates to the contentPane so calling form.add(cmp) is equivalent to
form.getContentPane().add(cmp). Normally this shouldn’t matter, however in some cases such as
animation we need to use the content pane directly e.g. form.getContentPane().animateLayout(200)
will work whereas form.animateLayout(200) will fail.
Nested types
class Form.TabIterator | Iterates through the components on this form in traversal order. |
Fields
protected boolean focusScrolling | Indicates whether lists and containers should scroll only via focus and thus “jump” when moving to a larger component as was the case in older versions of Codename One. |
Constructors
public Form() | Default constructor creates a simple form |
public Form(Layout contentPaneLayout) | Constructor that accepts a layout |
public Form(String title) | Sets the title after invoking the constructor |
public Form(String title, Layout contentPaneLayout) | Sets the title after invoking the constructor |
Methods
public void setAllowEnableLayoutOnPaint(boolean allow) | Enabling “layoutOnPaint” behaviour. |
public void addPasteListener(ActionListener l) | Adds a listener to be notified when the user has initiated a paste event. |
public void removePasteListener(ActionListener l) | Removes listener from being notified when the user has initiated a paste event. |
public void dispatchPaste(ActionEvent l) | Fires a paste event to the paste listeners. |
public TextSelection getTextSelection() | Gets TextSelection support for this form. |
public boolean isEnableCursors() | Checks if custom cursors are enabled on this form. |
public void setEnableCursors(boolean e) | Enable or disable custom cursors on this form. |
public Command getSourceCommand() | Gets the source command that was used to navigate to this form. |
public void setSourceCommand(Command sourceCommand) | Sets the source command that was used to navigate to this form. |
public VirtualInputDevice getCurrentInputDevice() | Returns the current virtual input device in the form. |
public void setCurrentInputDevice(VirtualInputDevice device)
throws Exception | Sets the current virtual input device for the form. |
protected void initGlobalToolbar() | Allows subclasses to disable the global toolbar for a specific form by overriding this method |
public void setOverrideInvisibleAreaUnderVKB(int invisibleAreaUnderVKB) | Overrides the invisible area under the virtual keyboard with a given value. |
public int getInvisibleAreaUnderVKB() | In some virtual keyboard implementations (notably iOS) this value is used to determine the height of the virtual keyboard |
public AnimationManager getAnimationManager() | Returns the animation manager instance responsible for this form, this can be used to track/queue animations |
public boolean isFormBottomPaddingEditingMode() | Toggles the way the virtual keyboard behaves, enabling this mode shrinks the screen but makes editing possible when working with text fields that aren’t in a scrollable container. |
public void setFormBottomPaddingEditingMode(boolean b) | Toggles the way the virtual keyboard behaves, enabling this mode shrinks the screen but makes editing possible when working with text fields that aren’t in a scrollable container. |
public Rectangle getSafeArea() | This method returns a rectangle defining the “safe” area of the display, which excludes areas on the screen that are covered by notches, task bars, rounded corners, etc. |
protected boolean shouldPaintStatusBar() | This method returns the value of the theme constant paintsTitleBarBool and it is invoked internally in the code. |
protected Component createStatusBar() | Subclasses can override this method to control the creation of the status bar component. |
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) |
public boolean grabAnimationLock() | Deprecated Allows grabbing a flag that is used by convention to indicate that you are running an exclusive animation. |
public void releaseAnimationLock() | Deprecated Invoke this to release the animation lock that was grabbed in grabAnimationLock |
public Component findCurrentlyEditingComponent() | Returns the component on this form that is currently being edited, or null if no component is currently being edited. |
public Container getTitleArea() | Deprecated Title area manipulation might break with future changes to Codename One and might damage themeing/functionality of the Codename One application in some platforms |
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 void addShowListener(ActionListener l) | This listener would be invoked when show is completed |
public void removeShowListener(ActionListener l) | Removes the show listener |
public void removeAllShowListeners() | Removes all Show Listeners from this Form |
public void addOrientationListener(ActionListener l) | This listener is invoked when device orientation changes on devices that support orientation change |
public void removeOrientationListener(ActionListener l) | This listener is invoked when device orientation changes on devices that support orientation change |
public void addSizeChangedListener(ActionListener l) | This listener is invoked when device size is changed |
public void removeSizeChangedListener(ActionListener l) | Remove SizeChangedListener |
protected void hideNotify() | This method is only invoked when the underlying canvas for the form is hidden this method isn’t called for form based events and is generally usable for suspend/resume based behavior |
protected void showNotify() | This method is only invoked when the underlying canvas for the form is shown this method isn’t called for form based events and is generally usable for suspend/resume based behavior |
protected void sizeChanged(int w, int h) | This method is only invoked when the underlying canvas for the form gets a size changed event. |
public void setSafeAreaChanged() | Causes the display safe area to be recalculated the next time the form list laid out. |
public boolean isDragRegion(int x, int y) | Deprecated Indicates if the section within the X/Y area is a “drag region” where we expect people to drag and never actually “press” in which case we can instantly start dragging making perceived performance faster. |
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 Painter getGlassPane() | Allows a developer that doesn’t derive from the form to draw on top of the form regardless of underlying changes or animations. |
public void setGlassPane(Painter glassPane) | Allows a developer that doesn’t derive from the form to draw on top of the form regardless of underlying changes or animations. |
public Label getTitleComponent() | Allows modifying the title attributes beyond style (e.g. setting icon/alignment etc.) |
public void setTitleComponent(Label title) | Allows replacing the title with a different title component, thus allowing developers to create more elaborate title objects. |
public void setTitleComponent(Label title, Transition t) | Allows replacing the title with a different title component, thus allowing developers to create more elaborate title objects. |
public void addKeyListener(int keyCode, ActionListener listener) | Add a key listener to the given keycode for a callback when the key is released |
public void removeKeyListener(int keyCode, ActionListener listener) | Removes a key listener from the given keycode |
public void removeGameKeyListener(int keyCode, ActionListener listener) | Removes a game key listener from the given game keycode |
public void addGameKeyListener(int keyCode, ActionListener listener) | Add a game key listener to the given gamekey for a callback when the key is released |
public final int getSoftButtonCount() | Returns the number of buttons on the menu bar for use with getSoftButton() |
public Button getSoftButton(int offset) | Returns the button representing the softbutton, this allows modifying softbutton attributes and behavior programmatically rather than by using the command API. |
public Style getMenuStyle() | Returns the style of the menu |
public Style getTitleStyle() | Returns the style of the title |
public void setTitleStyle(Style s) | Deprecated Sets the style of the title programmatically |
protected void initLaf(UIManager uim) | This method initializes the Component defaults constants |
public Command getDefaultCommand() | Default command is invoked when a user presses fire, this functionality works well in some situations but might collide with elements such as navigation and combo boxes. |
public void setDefaultCommand(Command defaultCommand) | Default command is invoked when a user presses fire, this functionality works well in some situations but might collide with elements such as navigation and combo boxes. |
public Command getClearCommand() | Indicates the command that is defined as the clear command in this form. |
public void setClearCommand(Command clearCommand) | Indicates the command that is defined as the clear command in this form. |
public Command setBackCommand(String name, Image icon, ActionListener ev) | Shorthand for #setBackCommand(com.codename1.ui.Command) that dynamically creates the command using com.codename1.ui.Image, com.codename1.ui.events.ActionListener). |
public Command getBackCommand() | Indicates the command that is defined as the back command out of this form. |
public void setBackCommand(Command backCommand) | Indicates the command that is defined as the back command out of this form. |
public void setPopGuard(PopGuard guard) | Installs an optional guard that is consulted before back/pop navigation leaves this form. |
public PopGuard getPopGuard() | Returns the currently installed pop guard, or null. |
public boolean checkPopGuard(PopReason reason) | Consults the installed pop guard for the given reason. |
public Container getContentPane() | This method returns the Content pane instance |
public Container asContainer() | |
public Container getLayeredPane() | This method returns the layered pane of the Form, the layered pane is laid on top of the content pane and is created lazily upon calling this method the layer will be created. |
public Container getLayeredPane(Class c, boolean top) | Returns the layered pane for the class and if one doesn’t exist a new one is created dynamically and returned |
public Container getLayeredPane(Class c, int zIndex) | Returns the layered pane for the class and if one doesn’t exist a new one is created dynamically and returned |
public Container getFormLayeredPane(Class c, boolean top) | Returns the layered pane for the class and if one doesn’t exist a new one is created dynamically and returned. |
protected Container getLayeredPaneIfExists() | Gets the layered pane of the container without trying to create it. |
protected Container getFormLayeredPaneIfExists() | Gets the form layered pane of the container without trying to create it. |
public void removeAll() | Removes all Components from the Content Pane |
public void setBgImage(Image bgImage) | Deprecated Sets the background image to show behind the form |
public void stopEditing(Runnable onFinish) | Stops any active editing on the form. |
public boolean isEditing() | Checks if the component is currently being edited. |
public String getTitle() | Returns the Form title text |
public void setTitle(String title) | Sets the Form title to the given text |
public void addComponent(Component cmp) | Adds Component to the Form’s Content Pane |
public void addComponent(Object constraints, Component cmp) | Adds a Component to the Container |
public void addComponent(int index, Object constraints, Component cmp) | Adds a Component to the Container |
public void addComponent(int index, Component cmp) | Adds Component to the Form’s Content Pane |
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 removeComponent(Component cmp) | Removes a component from the Form’s Content Pane |
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 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 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 boolean isTopLevelShowing() | Whether this top level is the one currently on screen. |
public final boolean hasMedia() | Used by the implementation to prevent flickering when flushing the double buffer |
public final void registerAnimated(Animation cmp) | The given component is interested in animating its appearance and will start receiving callbacks when it is visible in the form allowing it to animate its appearance. |
protected void onRegisterAnimated(Animation cmp) | Callback that’s invoked by registerAnimated to let subclasses keep track of animation registration. |
public void deregisterAnimated(Animation cmp) | Indicate that cmp would no longer like to receive animation events |
public boolean animate() | Allows the animation to reduce “repaint” calls when it returns false. |
public int getSideGap() | The form itself should |
protected void paintScrollbars(Graphics g) | Paints the UI for the scrollbars on the component, this will be invoked only for scrollable components. |
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 paintBackground(Graphics g) | Exposing the background painting for the benefit of animations |
public Transition getTransitionInAnimator() | This property allows us to define a an animation that will draw the transition for entering this form. |
public void setTransitionInAnimator(Transition transitionInAnimator) | This property allows us to define a an animation that will draw the transition for entering this form. |
public Transition getTransitionOutAnimator() | This property allows us to define a an animation that will draw the transition for exiting this form. |
public void setTransitionOutAnimator(Transition transitionOutAnimator) | This property allows us to define a an animation that will draw the transition for exiting this form. |
public void addCommandListener(ActionListener l) | A listener that is invoked when a command is clicked allowing multiple commands to be handled by a single block |
public void removeCommandListener(ActionListener l) | A listener that is invoked when a command is clicked allowing multiple commands to be handled by a single block |
protected void actionCommand(Command cmd) | Invoked to allow subclasses of form to handle a command from one point rather than implementing many command instances. |
public void dispatchCommand(Command cmd, ActionEvent ev) | Dispatches a command via the standard form mechanism of firing a command event |
public void show() | Displays the current form on the screen |
public void showBack() | Displays the current form on the screen, this version of the method is useful for “back” navigation since it reverses the direction of the transition. |
public void addPointerPressedListener(ActionListener l) | Adds a listener to the pointer event |
public void removePointerPressedListener(ActionListener l) | Removes the listener from the pointer event |
public void addPointerDraggedListener(ActionListener l) | Adds a listener to the pointer event |
public void removePointerDraggedListener(ActionListener l) | Removes the listener from the pointer event |
public void addPointerReleasedListener(ActionListener l) | Adds a listener to the pointer event |
public void removePointerReleasedListener(ActionListener l) | Removes the listener from the pointer event |
public void addLongPressListener(ActionListener l) | Adds a listener to the pointer event |
public void removeLongPressListener(ActionListener l) | Removes the listener from the pointer event |
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 |
protected void onShow() | Allows subclasses to bind functionality that occurs when a specific form or dialog appears on the screen |
protected void onShowCompleted() | Allows subclasses to bind functionality that occurs when a specific form or dialog is “really” showing hence when the transition is totally complete (unlike onShow which is called on intent). |
public final Form getComponentForm() | Returns the Component Form or null if this Component is not added yet to a form |
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 Component getFocused() | Returns the current focus component for this form |
public void setFocused(Component focused) | Sets the focused component and fires the appropriate events to make it so |
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 |
protected boolean shouldSendPointerReleaseToOtherForm() | Indicates whether this form wants to receive pointerReleased events for touch events that started in a different form |
public Component getNextComponent(Component current) | Gets the next component in focus traversal order. |
public Component getPreviousComponent(Component current) | Gets the previous component in focus traversal order. |
public Form.TabIterator getTabIterator(Component start) | Returns an iterator that iterates over all of the components in this form, ordered by their tab index. |
public void keyPressed(int keyCode) | If this Component is focused, the key pressed event will call this method |
public Layout getLayout() | Returns the layout manager of the form’s content pane. |
public void setLayout(Layout layout) | Sets the layout manager responsible for arranging this container |
public boolean isMinimizeOnBack() | When set to true the physical back button will minimize the application |
public void setMinimizeOnBack(boolean minimizeOnBack) | When set to true the physical back button will minimize the application |
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. |
protected boolean resumeDragAfterScrolling(int x, int y) | This method fixes this tensile drag issue. |
public void pointerPressed(int x, int y) | If this Component is focused, the pointer pressed event will call this method |
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 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 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 void pointerHover(int[] x, int[] y) | Invoked for devices where the pointer can hover without actually clicking the display. |
public boolean isSingleFocusMode() | Returns true if there is only one focusable member in this form. |
public void pointerReleased(int x, int y) | If this Component is focused, the pointer released event will call this method |
public boolean isScrollVisible() | Indicate whether this component scroll is visible |
public void setScrollVisible(boolean isScrollVisible) | Set whether this component scroll is visible |
public int getComponentIndex(Component cmp) | Returns the Component index in the Container |
public void addCommand(Command cmd, int offset) | Deprecated Adds a command to the menu bar softkeys or into the menu dialog, this version of add allows us to place a command in an arbitrary location. |
public int getCommandCount() | Deprecated A helper method to check the amount of commands within the form menu |
public Command getCommand(int index) | Returns the command occupying the given index |
public final void addCommand(Command cmd) | Deprecated Adds a command to the menu bar softkeys. |
public void removeCommand(Command cmd) | Removes the command from the menu bar softkeys |
public Component findNextFocusVertical(boolean down) | This method returns the next focusable Component vertically |
public Component findNextFocusHorizontal(boolean right) | This method returns the next focusable Component horizontally |
public boolean isCyclicFocus() | Indicates whether focus should cycle within the form |
public void setCyclicFocus(boolean cyclicFocus) | Indicates whether focus should cycle within the form |
public void scrollComponentToVisible(Component c) | Makes sure the component is visible in the scroll if this container is scrollable |
public void setMenuCellRenderer(ListCellRenderer menuCellRenderer) | Determine the cell renderer used to render menu elements for themeing the look of the menu options |
public void removeAllCommands() | Clear menu commands from the menu bar |
public void setRTL(boolean r) | Is the component a bidi RTL component |
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 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 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 void setVisible(boolean visible) | Toggles visibility of the component |
public int getTintColor() | Default color for the screen tint when a dialog or a menu is shown |
public void setTintColor(int tintColor) | Default color for the screen tint when a dialog or a menu is shown |
public void setMenuTransitions(Transition transitionIn, Transition transitionOut) | Sets the menu transitions for showing/hiding the menu, can be null… |
protected String paramString() | Returns a string representing the state of this component. |
public MenuBar getMenuBar() | Returns the associated Menu Bar object |
public void setMenuBar(MenuBar menuBar) | Sets the associated MenuBar Object. |
public void setToolBar(Toolbar toolbar) | Deprecated Sets the Form Toolbar |
public Toolbar getToolbar() | Gets the Form Toolbar if exists or null |
public void setToolbar(Toolbar toolbar) | Sets the Form Toolbar |
public boolean isFocusScrolling() | Indicates whether lists and containers should scroll only via focus and thus “jump” when moving to a larger component as was the case in older versions of Codename One. |
public void setFocusScrolling(boolean focusScrolling) | Indicates whether lists and containers should scroll only via focus and thus “jump” when moving to a larger component as was the case in older versions of Codename One. |
public String[] getPropertyNames() | A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code |
public Class[] getPropertyTypes() | Matches the property names method (see that method for further details). |
public String[] getPropertyTypeNames() | This method is here to workaround an XMLVM array type bug where property types aren’t identified properly, it returns the names of the types using the following type names: String,int,double,long,byte,short,char,String[],String[][],byte[],I… |
public Object getPropertyValue(String name) | Returns the current value of the property name, this method is used by the GUI builder |
public String setPropertyValue(String name, Object value) | Sets a new value to the given property, returns an error message if failed and null if successful. |
public TextArea getEditOnShow() | A text component that will receive focus and start editing immediately as the form is shown |
public void setEditOnShow(TextArea editOnShow) | A text component that will receive focus and start editing immediately as the form is shown |
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, 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, 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, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, 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, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, 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, 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, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, mouseWheel, paintRippleOverlay, removeDragFinishedListener, getDragSpeed, getStyle, getPressedStyle, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, 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, 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
focusScrolling
protected boolean focusScrollingConstructor details
Form
public Form()Form
public Form(Layout contentPaneLayout)Parameters
contentPaneLayoutLayout- the layout for the content pane
Form
public Form(String title)Parameters
titleString- the form title
Form
public Form(String title, Layout contentPaneLayout)Parameters
titleString- the form title
contentPaneLayoutLayout- the layout for the content pane
Method details
setAllowEnableLayoutOnPaint
public void setAllowEnableLayoutOnPaint(boolean allow)Enabling “layoutOnPaint” behaviour. Setting this flag to true will cause this form and all of its containers to lay themselves out whenever they are painted. This carries a performance penalty.
Historical Note: “layoutOnPaint” behaviour has been “on” since the original commit to Google code in 2012, but it isn’t clear, now, why it was necessary. It was likely to fix an edge case in certain layouts that is no longer relevant. As of 7.0, we are disabling this behaviour by default because it carries such performance penalties, but allowing developers to opt-in to it using this method.
Parameters
allowboolean- Whether to allow layoutOnPaint behaviour in this this form and it’s containers.
addPasteListener
public void addPasteListener(ActionListener l)Adds a listener to be notified when the user has initiated a paste event. This will primarily occur only on desktop devices which allow the user to initiate a paste outside the UI of the app itself, either using a key code (Command/Ctrl V), or a menu (Edit > Paste).
The event will be fired after the paste action has updated the clipboard contents, so you can
access the clipboard contents via Display#getPasteDataFromClipboard().
Parameters
lActionListener- Listener registered to receive paste events.
removePasteListener
public void removePasteListener(ActionListener l)Parameters
lActionListener- Listener to unregister to receive paste events.
dispatchPaste
public void dispatchPaste(ActionEvent l)Parameters
lActionEvent- The paste event. Includes no useful data currently.
getTextSelection
public TextSelection getTextSelection()Returns
isEnableCursors
public boolean isEnableCursors()Returns
setEnableCursors
public void setEnableCursors(boolean e)Parameters
eboolean- True to enable cursors. False to disable them.
See also
getSourceCommand
public Command getSourceCommand()Returns
setSourceCommand
public void setSourceCommand(Command sourceCommand)Parameters
sourceCommandCommand- The source command.
getCurrentInputDevice
public VirtualInputDevice getCurrentInputDevice()Returns
setCurrentInputDevice
public void setCurrentInputDevice(VirtualInputDevice device)
throws ExceptionSets the current virtual input device for the form. This will execute the VirtualInputDevice#close()
method of the current input device, and then set device as the new current input device.
Some examples of virtual input devices are the Picker widget and the virtual keyboard.
Throws
initGlobalToolbar
protected void initGlobalToolbar()setOverrideInvisibleAreaUnderVKB
public void setOverrideInvisibleAreaUnderVKB(int invisibleAreaUnderVKB)Overrides the invisible area under the virtual keyboard with a given value. This is used by lightweight components
to simulate the virtual keyboard, so that they will respect #setFormBottomPaddingEditingMode(boolean).
Warning: This setting is generally for internal use only, and should only be used if you know what you are doing. After setting this value to a non-negative value, it will override the “real” area under the VKB if the read VKB is shown.
To reset this after the lightweight component is hidden, set the value to -1.
Parameters
invisibleAreaUnderVKBint- The area hidden by the VKB in pixels.
getInvisibleAreaUnderVKB
public int getInvisibleAreaUnderVKB()Returns
getAnimationManager
public AnimationManager getAnimationManager()Returns
isFormBottomPaddingEditingMode
public boolean isFormBottomPaddingEditingMode()Returns
setFormBottomPaddingEditingMode
public void setFormBottomPaddingEditingMode(boolean b)Parameters
bboolean- true to enable false to disable
getSafeArea
public Rectangle getSafeArea()This method returns a rectangle defining the “safe” area of the display, which excludes areas on the screen that are covered by notches, task bars, rounded corners, etc.
This feature was primarily added to deal with the task bar on the iPhone X, which is displayed on the screen near the bottom edge, and can interfere with components that are laid out at the bottom of the screen.
Most platforms will simply return a Rectangle with bounds (0, 0, displayWidth, displayHeight). iPhone X will return a rectangle that excludes the notch, and task bar regions.
Returns
See also
CodenameOneImplementation#getDisplaySafeArea(com.codename1.ui.geom.Rectangle)Container#setSafeArea(boolean)Container#isSafeArea()
shouldPaintStatusBar
protected boolean shouldPaintStatusBar()paintsTitleBarBool and it is
invoked internally in the code. You can override this method to toggle the appearance of the status
bar on a per-form basisReturns
paintsTitleBarBool theme constantcreateStatusBar
protected Component createStatusBar()Returns
isAlwaysTensile
public boolean isAlwaysTensile()Returns
setAlwaysTensile
public void setAlwaysTensile(boolean alwaysTensile)Parameters
alwaysTensileboolean- the alwaysTensile to set
grabAnimationLock
public boolean grabAnimationLock()Returns
releaseAnimationLock
public void releaseAnimationLock()findCurrentlyEditingComponent
public Component findCurrentlyEditingComponent()Returns
See also
getTitleArea
public Container getTitleArea()Returns
getUIManager
public UIManager getUIManager()Returns
setUIManager
public void setUIManager(UIManager uiManager)Parameters
uiManagerUIManager- UIManager instance
addShowListener
public void addShowListener(ActionListener l)Parameters
lActionListener- listener
removeShowListener
public void removeShowListener(ActionListener l)Parameters
lActionListener- the listener
removeAllShowListeners
public void removeAllShowListeners()addOrientationListener
public void addOrientationListener(ActionListener l)Parameters
lActionListener- listener
removeOrientationListener
public void removeOrientationListener(ActionListener l)Parameters
lActionListener- the listener
addSizeChangedListener
public void addSizeChangedListener(ActionListener l)Parameters
lActionListener- listener
removeSizeChangedListener
public void removeSizeChangedListener(ActionListener l)Parameters
lActionListener- the listener
hideNotify
protected void hideNotify()showNotify
protected void showNotify()sizeChanged
protected void sizeChanged(int w, int h)Parameters
wint- the new width of the Form
hint- the new height of the Form
setSafeAreaChanged
public void setSafeAreaChanged()See also
isDragRegion
public boolean isDragRegion(int x, int y)Parameters
xint- x location for the touch
yint- y location for the touch
Returns
getDragRegionStatus
public int getDragRegionStatus(int x, int y)Parameters
xint- x location for the touch
yint- y location for the touch
Returns
getGlassPane
public Painter getGlassPane()Allows a developer that doesn’t derive from the form to draw on top of the form regardless of underlying changes or animations. This is useful for watermarks or special effects (such as tinting) it is also useful for generic drawing of validation errors etc… A glass pane is generally transparent or translucent and allows the the UI below to be seen.
The example shows a glasspane running on top of a field to show a validation hint,
notice that for real world usage you should probably look into com.codename1.ui.validation.Validator
Form hi = new Form("Glass Pane", new BoxLayout(BoxLayout.Y_AXIS));
Style s = UIManager.getInstance().getComponentStyle("Label");
s.setFgColor(0xff0000);
s.setBgTransparency(0);
Image warningImage = FontImage.createMaterial(FontImage.MATERIAL_WARNING, s).toImage();
TextField tf1 = new TextField("My Field");
tf1.getAllStyles().setMarginUnit(Style.UNIT_TYPE_DIPS);
tf1.getAllStyles().setMargin(5, 5, 5, 5);
hi.add(tf1);
hi.setGlassPane((g, rect) -> {
int x = tf1.getAbsoluteX() + tf1.getWidth();
int y = tf1.getAbsoluteY();
x -= warningImage.getWidth() / 2;
y += (tf1.getHeight() / 2 - warningImage.getHeight() / 2);
g.drawImage(warningImage, x, y);
});
hi.show();
Returns
setGlassPane
public void setGlassPane(Painter glassPane)Allows a developer that doesn’t derive from the form to draw on top of the form regardless of underlying changes or animations. This is useful for watermarks or special effects (such as tinting) it is also useful for generic drawing of validation errors etc… A glass pane is generally transparent or translucent and allows the the UI below to be seen.
The example shows a glasspane running on top of a field to show a validation hint,
notice that for real world usage you should probably look into com.codename1.ui.validation.Validator
Form hi = new Form("Glass Pane", new BoxLayout(BoxLayout.Y_AXIS));
Style s = UIManager.getInstance().getComponentStyle("Label");
s.setFgColor(0xff0000);
s.setBgTransparency(0);
Image warningImage = FontImage.createMaterial(FontImage.MATERIAL_WARNING, s).toImage();
TextField tf1 = new TextField("My Field");
tf1.getAllStyles().setMarginUnit(Style.UNIT_TYPE_DIPS);
tf1.getAllStyles().setMargin(5, 5, 5, 5);
hi.add(tf1);
hi.setGlassPane((g, rect) -> {
int x = tf1.getAbsoluteX() + tf1.getWidth();
int y = tf1.getAbsoluteY();
x -= warningImage.getWidth() / 2;
y += (tf1.getHeight() / 2 - warningImage.getHeight() / 2);
g.drawImage(warningImage, x, y);
});
hi.show();
Parameters
glassPanePainter- a new glass pane to install. It is generally recommended to use a painter chain if more than one painter is required.
getTitleComponent
public Label getTitleComponent()Returns
setTitleComponent
public void setTitleComponent(Label title)Parameters
titleLabel- new title component
setTitleComponent
public void setTitleComponent(Label title, Transition t)Parameters
titleLabel- new title component
tTransition- transition for title replacement
addKeyListener
public void addKeyListener(int keyCode, ActionListener listener)Parameters
keyCodeint- code on which to send the event
listenerActionListener- listener to invoke when the key code released.
removeKeyListener
public void removeKeyListener(int keyCode, ActionListener listener)Parameters
keyCodeint- code on which the event is sent
listenerActionListener- listener instance to remove
removeGameKeyListener
public void removeGameKeyListener(int keyCode, ActionListener listener)Parameters
keyCodeint- code on which the event is sent
listenerActionListener- listener instance to remove
addGameKeyListener
public void addGameKeyListener(int keyCode, ActionListener listener)Parameters
keyCodeint- code on which to send the event
listenerActionListener- listener to invoke when the key code released.
getSoftButtonCount
public final int getSoftButtonCount()Returns
getSoftButton
public Button getSoftButton(int offset)Parameters
offsetint- the offest of the softbutton
Returns
getMenuStyle
public Style getMenuStyle()Returns
getTitleStyle
public Style getTitleStyle()Returns
setTitleStyle
public void setTitleStyle(Style s)Parameters
sStyle- new style
initLaf
protected void initLaf(UIManager uim)getDefaultCommand
public Command getDefaultCommand()Returns
setDefaultCommand
public void setDefaultCommand(Command defaultCommand)Parameters
defaultCommandCommand- the command to treat as default
getClearCommand
public Command getClearCommand()Returns
setClearCommand
public void setClearCommand(Command clearCommand)Parameters
clearCommandCommand- the command to treat as the clear Command
setBackCommand
public Command setBackCommand(String name, Image icon, ActionListener ev)#setBackCommand(com.codename1.ui.Command) that
dynamically creates the command using com.codename1.ui.Image, com.codename1.ui.events.ActionListener).Parameters
nameString- the name/title of the command
iconImage- the icon for the command
evActionListener- the even handler
Returns
getBackCommand
public Command getBackCommand()Returns
setBackCommand
public void setBackCommand(Command backCommand)Parameters
backCommandCommand- the command to treat as the back Command
setPopGuard
public void setPopGuard(PopGuard guard)Installs an optional guard that is consulted before back/pop navigation leaves this form.
The guard fires for:
- The back command (toolbar / menu back button).
- Hardware back (Android back button, iOS edge-swipe back).
- Programmatic
com.codename1.router.Router#popandreplacecalls.
If the guard returns false the navigation is suppressed; the guard itself
is responsible for any follow-up UI (e.g. showing a confirm dialog and then
calling Router.pop() once the user accepts).
Pass null to remove a previously installed guard.
Since 7.0
See also
getPopGuard
public PopGuard getPopGuard()Returns the currently installed pop guard, or null.
Since 7.0
checkPopGuard
public boolean checkPopGuard(PopReason reason)Consults the installed pop guard for the given reason. Returns true when
no guard is installed or the guard permits the pop. Called by Router, by
the back-command dispatcher, by platform back-key glue, and may be called
by developer code that implements its own back navigation and wants to
honor any pop guard installed on the form.
Since 7.0
getContentPane
public Container getContentPane()Returns
asContainer
public Container asContainer()getLayeredPane
public Container getLayeredPane()Returns
getLayeredPane
public Container getLayeredPane(Class c, boolean top)Parameters
cClass- the class with which this layered pane is associated, null for the global layered pane which is always on the bottom
topboolean- if created this indicates whether the layered pane should be added on top or bottom
Returns
getLayeredPane
public Container getLayeredPane(Class c, int zIndex)Parameters
cClass- the class with which this layered pane is associated, null for the global layered pane which is always on the bottom
zIndexint- if created this indicates the zIndex at which the pane is placed. Higher z values in front of lower z values.
Returns
getFormLayeredPane
public Container getFormLayeredPane(Class c, boolean top)Parameters
cClass- the class with which this layered pane is associated, null for the global layered pane which is always on the bottom
topboolean- if created this indicates whether the layered pane should be added on top or bottom
Returns
getLayeredPaneIfExists
protected Container getLayeredPaneIfExists()#getLayeredPane()
hasn’t been called yet for the form, then the layered pane will be null.Returns
getFormLayeredPaneIfExists
protected Container getFormLayeredPaneIfExists()boolean)
hasn’t been called yet for the form, then the layered pane will be null.Returns
removeAll
public void removeAll()setBgImage
public void setBgImage(Image bgImage)Parameters
bgImageImage- the background image
stopEditing
public void stopEditing(Runnable onFinish)Parameters
onFinishRunnable- Callback to run on finish.
isEditing
public boolean isEditing()Returns
getTitle
public String getTitle()Returns
setTitle
public void setTitle(String title)Parameters
titleString- the form title
addComponent
public void addComponent(Component cmp)Parameters
cmpComponent- the added param
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, 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
addComponent
public void addComponent(int index, Component cmp)Parameters
indexint- location to insert the Component
cmpComponent- the added param
Throws
ArrayIndexOutOfBoundsException- if index is out of bounds
IllegalArgumentException- if Component is already contained or the cmp is a Form Component
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
removeComponent
public void removeComponent(Component cmp)Parameters
cmpComponent- the component to be removed
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
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
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
isTopLevelShowing
public boolean isTopLevelShowing()Returns
hasMedia
public final boolean hasMedia()Returns
registerAnimated
public final void registerAnimated(Animation cmp)Parameters
cmpAnimation- component that would be animated
onRegisterAnimated
protected void onRegisterAnimated(Animation cmp)Parameters
cmpAnimation- component that would be animated
deregisterAnimated
public void deregisterAnimated(Animation cmp)Parameters
cmpAnimation- component that would no longer receive animation events
animate
public boolean animate()com.codename1.ui.Display class.Returns
getSideGap
public int getSideGap()Returns
paintScrollbars
protected void paintScrollbars(Graphics g)Parameters
gGraphics- the component graphics
refreshTheme
public void refreshTheme(boolean merge)Parameters
mergeboolean- indicates if the current styles should be merged with the new styles
paintBackground
public void paintBackground(Graphics g)Parameters
gGraphics- the form graphics
getTransitionInAnimator
public Transition getTransitionInAnimator()Returns
setTransitionInAnimator
public void setTransitionInAnimator(Transition transitionInAnimator)Parameters
transitionInAnimatorTransition- the Form in transition
getTransitionOutAnimator
public Transition getTransitionOutAnimator()Returns
setTransitionOutAnimator
public void setTransitionOutAnimator(Transition transitionOutAnimator)Parameters
transitionOutAnimatorTransition- the Form out transition
addCommandListener
public void addCommandListener(ActionListener l)Parameters
lActionListener- the command action listener
removeCommandListener
public void removeCommandListener(ActionListener l)Parameters
lActionListener- the command action listener
actionCommand
protected void actionCommand(Command cmd)Parameters
cmdCommand- the form commmand object
dispatchCommand
public void dispatchCommand(Command cmd, ActionEvent ev)Parameters
cmdCommand- The command to dispatch
evActionEvent- the event to dispatch
show
public void show()showBack
public void showBack()addPointerPressedListener
public void addPointerPressedListener(ActionListener l)Adds a listener to the pointer event
While this form’s listeners live on a host – which is the case for the whole
time it is embedded, or hosted in a window – additions and removals have to go
there too. The host’s pointer dispatch is what drives the hierarchy, so a
listener added later (from onShow(), say) would sit in a dispatcher nothing
consults, and removing a transferred one would leave it firing on the host.
Parameters
lActionListener- callback to receive pointer events
removePointerPressedListener
public void removePointerPressedListener(ActionListener l)Parameters
lActionListener- callback to remove
addPointerDraggedListener
public void addPointerDraggedListener(ActionListener l)Parameters
lActionListener- callback to receive pointer events
removePointerDraggedListener
public void removePointerDraggedListener(ActionListener l)Parameters
lActionListener- callback to remove
addPointerReleasedListener
public void addPointerReleasedListener(ActionListener l)Parameters
lActionListener- callback to receive pointer events
removePointerReleasedListener
public void removePointerReleasedListener(ActionListener l)Parameters
lActionListener- callback to remove
addLongPressListener
public void addLongPressListener(ActionListener l)Parameters
lActionListener- callback to receive pointer events
removeLongPressListener
public void removeLongPressListener(ActionListener l)Parameters
lActionListener- callback to remove
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
onShow
protected void onShow()onShowCompleted
protected void onShowCompleted()getComponentForm
public final Form getComponentForm()Returns
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.
A Form terminates the walk unless it is itself embedded in another
hierarchy, exactly as #getComponentForm() does.
Returns
getFocused
public Component getFocused()Returns
setFocused
public void setFocused(Component focused)Parameters
focusedComponent- the newly focused component or null for no focus
longKeyPress
protected void longKeyPress(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
longPointerPress
public void longPointerPress(int x, int y)shouldSendPointerReleaseToOtherForm
protected boolean shouldSendPointerReleaseToOtherForm()Returns
getNextComponent
public Component getNextComponent(Component current)Component#getNextFocusRight()
if it is set. If not, it will return Component#getNextFocusDown() if it is set. If not, it will
return the next component according to the traversal order.Parameters
currentComponent- The current component.
Returns
getPreviousComponent
public Component getPreviousComponent(Component current)Component#getNextFocusLeft()
if it is set. If not, it will return Component#getNextFocusUp() if it is set. If not, it will
return the previous component according to the traversal order defined by Form#getTabIterator(com.codename1.ui.Component).Parameters
currentComponent- The current component.
Returns
getTabIterator
public Form.TabIterator getTabIterator(Component start)Parameters
startComponent- The start position. The iterator will automatically initialized such that
ListIterator#next()will return the next component in the traversal order, and theListIterator#previous()returns the previous component in traversal order.
Returns
keyPressed
public void keyPressed(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
getLayout
public Layout getLayout()Returns
See also
#getActualLayout()For the actual layout of the form.
setLayout
public void setLayout(Layout layout)Parameters
layoutLayout- the specified layout manager
isMinimizeOnBack
public boolean isMinimizeOnBack()Returns
setMinimizeOnBack
public void setMinimizeOnBack(boolean minimizeOnBack)Parameters
minimizeOnBackboolean- the minimizeOnBack to set
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.
resumeDragAfterScrolling
protected boolean resumeDragAfterScrolling(int x, int y)Parameters
xint- the x position of a pointer press operation
yint- the y position of a pointer press operation
Returns
pointerPressed
public void pointerPressed(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()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)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
pointerHover
public void pointerHover(int[] x, int[] y)Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
isSingleFocusMode
public boolean isSingleFocusMode()Returns
pointerReleased
public void pointerReleased(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
isScrollVisible
public boolean isScrollVisible()Returns
setScrollVisible
public void setScrollVisible(boolean isScrollVisible)Parameters
isScrollVisibleboolean- Indicate whether this component scroll is visible
getComponentIndex
public int getComponentIndex(Component cmp)Parameters
cmpComponent- the component to search for
Returns
addCommand
public void addCommand(Command cmd, int offset)Toolbar#addCommandToLeftBar(com.codename1.ui.Command) or similar methodsParameters
cmdCommand- the Form command to be added
offsetint- position in which the command is added
getCommandCount
public int getCommandCount()Toolbar#getComponentCount() or similar methodsReturns
getCommand
public Command getCommand(int index)Parameters
indexint- offset of the command
Returns
addCommand
public final void addCommand(Command cmd)Toolbar#addCommandToLeftBar(com.codename1.ui.Command) or similar methodsParameters
cmdCommand- the Form command to be added
removeCommand
public void removeCommand(Command cmd)Parameters
cmdCommand- the Form command to be removed
findNextFocusVertical
public Component findNextFocusVertical(boolean down)This method returns the next focusable Component vertically
NOTE: This method does NOT make use of Component#getNextFocusDown() or Component#getNextFocusUp().
It simply finds the next focusable component on the form based solely on absolute Y coordinate.
Parameters
downboolean- if true will the return the next focusable on the bottom else on the top
Returns
findNextFocusHorizontal
public Component findNextFocusHorizontal(boolean right)This method returns the next focusable Component horizontally
NOTE: This method does NOT make use of Component#getNextFocusLeft() or Component#getNextFocusRight().
It simply finds the next focusable component on the form based solely on absolute X coordinate.
Parameters
rightboolean- if true will the return the next focusable on the right else on the left
Returns
isCyclicFocus
public boolean isCyclicFocus()Returns
setCyclicFocus
public void setCyclicFocus(boolean cyclicFocus)Parameters
cyclicFocusboolean- marks whether focus should cycle
scrollComponentToVisible
public void scrollComponentToVisible(Component c)Parameters
cComponent- the componant to be visible
setMenuCellRenderer
public void setMenuCellRenderer(ListCellRenderer menuCellRenderer)Parameters
menuCellRendererListCellRenderer- the menu cell renderer
removeAllCommands
public void removeAllCommands()setRTL
public void setRTL(boolean r)Parameters
rboolean- true if the component should work in a right to left mode
paint
public void paint(Graphics g)Parameters
gGraphics- the component graphics
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
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
setVisible
public void setVisible(boolean visible)Parameters
visibleboolean- true if component is visible; otherwise false
getTintColor
public int getTintColor()Returns
setTintColor
public void setTintColor(int tintColor)Parameters
tintColorint- the tint color when a dialog or a menu is shown
setMenuTransitions
public void setMenuTransitions(Transition transitionIn, Transition transitionOut)Parameters
transitionInTransition- the transition that will play when the menu appears
transitionOutTransition- the transition that will play when the menu is folded
paramString
protected String paramString()null.Returns
getMenuBar
public MenuBar getMenuBar()Returns
setMenuBar
public void setMenuBar(MenuBar menuBar)setToolBar
public void setToolBar(Toolbar toolbar)getToolbar
public Toolbar getToolbar()Returns
setToolbar
public void setToolbar(Toolbar toolbar)isFocusScrolling
public boolean isFocusScrolling()Returns
setFocusScrolling
public void setFocusScrolling(boolean focusScrolling)Parameters
focusScrollingboolean- the new value for focus scrolling
getPropertyNames
public String[] getPropertyNames()Returns
getPropertyTypes
public Class[] getPropertyTypes()Returns
getPropertyTypeNames
public String[] getPropertyTypeNames()Returns
getPropertyValue
public Object getPropertyValue(String name)Parameters
nameString- the name of the property
Returns
setPropertyValue
public String setPropertyValue(String name, Object value)Parameters
nameString- the name of the property
valueObject- new value for the property
Returns
getEditOnShow
public TextArea getEditOnShow()Returns
setEditOnShow
public void setEditOnShow(TextArea editOnShow)Parameters
editOnShowTextArea- text component to edit when the form is shown