public class Component
- Object
- Component
ImplementsAnimation, Editable, StyleListener
Known subtypesChartComponent, ImageViewer, InfiniteProgress, Switch, CommonProgressAnimations.ProgressAnimation, Container, Label, List, PeerComponent, RichTextComponent, TextArea, EditorView
The component class is the basis of all UI widgets in Codename One, to arrange multiple components together we use the Container class which itself “IS A” Component subclass. The Container is a Component that contains Components effectively allowing us to nest Containers infinitely to build any type of visual hierarchy we want by nesting Containers.
Style Change Events
Styles fire a change event for each style change that occurs. Component listens to all changes events
of its styles, and adjusts some of its properties accordingly. Currently (as of 6.0) each style change will trigger
a Container#revalidate() call on the Style’s Component’s parent container, which is expensive. You can disable this
Container#revalidate() call by calling "false"). This will
likely be the default behavior in a future version, so we recommend you disable this explicitly for both performance reasons, and
to avoid regressions when the default is changed.
Fields
public static final int DEFAULT_CURSOR = 0 | The default cursor |
public static final int CROSSHAIR_CURSOR = 1 | The crosshair cursor type. |
public static final int TEXT_CURSOR = 2 | The text cursor type. |
public static final int WAIT_CURSOR = 3 | The wait cursor type. |
public static final int SW_RESIZE_CURSOR = 4 | The south-west-resize cursor type. |
public static final int SE_RESIZE_CURSOR = 5 | The south-east-resize cursor type. |
public static final int NW_RESIZE_CURSOR = 6 | The north-west-resize cursor type. |
public static final int NE_RESIZE_CURSOR = 7 | The north-east-resize cursor type. |
public static final int N_RESIZE_CURSOR = 8 | The north-resize cursor type. |
public static final int S_RESIZE_CURSOR = 9 | The south-resize cursor type. |
public static final int W_RESIZE_CURSOR = 10 | The west-resize cursor type. |
public static final int E_RESIZE_CURSOR = 11 | The east-resize cursor type. |
public static final int HAND_CURSOR = 12 | The hand cursor type. |
public static final int MOVE_CURSOR = 13 | The move cursor type. |
public static final int DRAG_REGION_NOT_DRAGGABLE = 1 | Used by getDragRegionStatus to indicate no dragability |
public static final int DRAG_REGION_POSSIBLE_DRAG_X = 10 | Used by getDragRegionStatus to indicate limited dragability |
public static final int DRAG_REGION_POSSIBLE_DRAG_Y = 11 | Used by getDragRegionStatus to indicate limited dragability |
public static final int DRAG_REGION_POSSIBLE_DRAG_XY = 12 | Used by getDragRegionStatus to indicate limited dragability |
public static final int DRAG_REGION_LIKELY_DRAG_X = 21 | Used by getDragRegionStatus to indicate likely dragability |
public static final int DRAG_REGION_LIKELY_DRAG_Y = 22 | Used by getDragRegionStatus to indicate likely dragability |
public static final int DRAG_REGION_LIKELY_DRAG_XY = 23 | Used by getDragRegionStatus to indicate likely dragability |
public static final int DRAG_REGION_IMMEDIATELY_DRAG_X = 31 | Used by getDragRegionStatus to indicate immediate dragability |
public static final int DRAG_REGION_IMMEDIATELY_DRAG_Y = 32 | Used by getDragRegionStatus to indicate immediate dragability |
public static final int DRAG_REGION_IMMEDIATELY_DRAG_XY = 33 | Used by getDragRegionStatus to indicate immediate dragability |
public static final int BRB_CONSTANT_ASCENT = 1 | Baseline resize behavior constant used to properly align components. |
public static final int BRB_CONSTANT_DESCENT = 2 | Baseline resize behavior constant used to properly align components. |
public static final int BRB_CENTER_OFFSET = 3 | Baseline resize behavior constant used to properly align components. |
public static final int BRB_OTHER = 4 | Baseline resize behavior constant used to properly align components. |
public static final int CENTER = 4 | Indicates a Component center alignment |
public static final int TOP = 0 | Box-orientation constant used to specify the top of a box. |
public static final int LEFT = 1 | Box-orientation constant used to specify the left side of a box. |
public static final int BOTTOM = 2 | Box-orientation constant used to specify the bottom of a box. |
public static final int RIGHT = 3 | Box-orientation constant used to specify the right side of a box. |
public static final int BASELINE = 5 | Alignment to the baseline constraint |
Constructors
protected Component() | Creates a new instance of Component |
Methods
public static void setSameSize(Component... c) | This is identical to invoking #sameWidth followed by #sameHeight |
public static boolean isSetCursorSupported() | Checks to see if this platform supports cursors. |
public static Dimension parsePreferredSize(String preferredSize, Dimension baseSize) | Parses the preferred size given as a string |
public static byte getDefaultDragTransparency() | Returns the default translucency used in the #getDragImage() method. |
public static void setDefaultDragTransparency(byte defaultDragTransparency) | Sets the default translucency of the #getDragImage() method. |
public Editable getEditingDelegate() | Gets the delegate that handles the editing of this component. |
public void setEditingDelegate(Editable editable) | Sets the editing delegate for this component. |
public int getCursor() | Gets the custom cursor for this component. |
public void setCursor(int cursor) | Sets a custom mouse cursor for this component if the platform supports mouse cursors, notice that this isn’t applicable for touch devices. |
protected void showNativeOverlay() | Creates the native overlay for this component. |
protected void hideNativeOverlay() | Hides the native overlay for this component. |
protected void updateNativeOverlay() | Updates the native overlay for this component. |
public Object getNativeOverlay() | Gets the native overlay for this component. |
public final Style getAllStyles() | Returns a “meta style” that allows setting styles once to all the different Style objects, the getters for this style will be meaningless and will return 0 values. |
public Component[] getSameWidth() | Returns the array of components that have an equal width |
public static void setSameWidth(Component... c) | Places all of these components in the same width group, to remove a component from the group invoke this method with that component only. |
public Component[] getSameHeight() | Returns the array of components that have an equal height |
public static void setSameHeight(Component... c) | Places all of these components in the same height group, to remove a component from the group invoke this method with that component only. |
protected void initLaf(UIManager uim) | This method initializes the Component defaults constants |
public UIManager getUIManager() | This method should be used by the Component to retrieve the correct UIManager to work with |
public int getX() | Returns the current component x location relatively to its parent container |
public void setX(int x) | Sets the Component x location relative to the parent container, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
public int getOuterX() | Gets the x-coordinate of the outer bounds of this component. |
public int getInnerX() | Gets x-coordinate of the inner bounds of this component. |
public int getY() | Returns the component y location relatively to its parent container |
public void setY(int y) | Sets the Component y location relative to the parent container, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
public int getOuterY() | Gets the Y-coordinate of the outer bounds of this component. |
public int getInnerY() | Gets the inner y-coordinate of the inner bounds of this component. |
public boolean isVisible() | Returns whether the component is visible or not |
public void setVisible(boolean visible) | Toggles visibility of the component |
public Object getClientProperty(String key) | Client properties allow the association of meta-data with a component, this is useful for some applications that construct GUI’s on the fly and need to track the connection between the UI and the data. |
public Component stripMarginAndPadding() | Convenience method that strips margin and padding from the component, and returns itself for chaining. |
public void clearClientProperties() | Clears all client properties from this Component |
public void putClientProperty(String key, Object value) | Client properties allow the association of meta-data with a component, this is useful for some applications that construct GUI’s on the fly and need to track the connection between the UI and the data. |
public final Rectangle getDirtyRegion() | gets the Component dirty region, this method is for internal use only and SHOULD NOT be invoked by user code. |
public final void setDirtyRegion(Rectangle dirty) | sets the Component dirty region, this method is for internal use only and SHOULD NOT be invoked by user code. |
public boolean isOpaque() | Checks whether the component’s background should be painted. |
public final void setOpaque(boolean opaque) | Sets whether or not to paint the component background. |
public int getWidth() | Returns the component width |
public void setWidth(int width) | Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
public int getOuterWidth() | Gets the outer width of this component. |
public int getInnerWidth() | Gets the inner width of this component. |
public int getHeight() | Returns the component height |
public void setHeight(int height) | Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
public int getOuterHeight() | Gets the outer height of this component. |
public int getInnerHeight() | Gets the inner height of this component. |
protected 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. |
protected 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 int getBaseline(int width, int height) | The baseline for the component text according to which it should be aligned with other components for best visual look. |
public int getBaselineResizeBehavior() | Returns a constant indicating how the baseline varies with the size of the component. |
public String getPreferredSizeStr() | Deprecated Returns the preferred size string that can be used to specify the preferred size of the component using pixels or millimetres. |
public void setPreferredSizeStr(String value) | Deprecated |
public Dimension getPreferredSize() | Returns the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size. |
public void setPreferredSize(Dimension d) | Deprecated Sets the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size. |
public Dimension getScrollDimension() | Returns the Components dimension in scrolling, this is very similar to the preferred size aspect only it represents actual scrolling limits. |
protected Dimension calcScrollSize() | Method that can be overriden to represent the actual size of the component when it differs from the desireable size for the viewport |
public void setScrollSize(Dimension d) | Set the size for the scroll area |
public int getPreferredW() | Helper method to retrieve the preferred width of the component. |
public void setPreferredW(int preferredW) | Deprecated Helper method to set the preferred width of the component. |
public int getPreferredH() | Helper method to retrieve the preferred height of the component. |
public void setPreferredH(int preferredH) | Deprecated Helper method to set the preferred height of the component. |
public int getOuterPreferredH() | Gets the preferred height including the vertical margins. |
public int getInnerPreferredH() | Gets the preferred height removing vertical padding. |
public int getOuterPreferredW() | Gets the preferred width including horizontal margins. |
public int getInnerPreferredW() | Gets the preferred width removing horizontal padding. |
public void setSize(Dimension d) | Sets the Component size, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
public final String getUIID() | Unique identifier for a component. |
public void setUIID(String id) | This method sets the Component the Unique identifier. |
protected final void setUIIDFinal(String id) | This method is the implementation of setUIID and is defined as final to allow invocation from constructors. |
public void setUIID(String portraitUiid, String landscapeUiid) | This method sets the Component the Unique identifier. |
public String getInlineAllStyles() | Gets inline styles that are to be applied to all states of this component. |
public void setInlineAllStyles(String styles) | Registers inline styles that should be applied to all states of the component. |
public String getInlineSelectedStyles() | Gets inline styles that are to be applied to the selected state of this component. |
public void setInlineSelectedStyles(String styles) | Registers inline styles that should be applied to the selected state of the component. |
public String getInlineUnselectedStyles() | Gets inline styles that are to be applied to the unselected state of this component. |
public void setInlineUnselectedStyles(String styles) | Registers inline styles that should be applied to the unselected state of the component. |
public String getInlineDisabledStyles() | Gets inline styles that are to be applied to the disabled state of this component. |
public void setInlineDisabledStyles(String styles) | Registers inline styles that should be applied to the disabled state of the component. |
public String getInlinePressedStyles() | Gets inline styles that are to be applied to the pressed state of this component. |
public void setInlinePressedStyles(String styles) | Registers inline styles that should be applied to the pressed state of the component. |
public void remove() | This method will remove the Component from its parent. |
public Container getParent() | Returns the container in which this component is contained |
public Component getOwner() | Gets the “owner” of this component as set by #setOwner(com.codename1.ui.Component). |
public void setOwner(Component owner) | Sets the owner of this component to the specified component. |
public boolean isOwnedBy(Component cmp) | Checks to see if this component is owned by the given other component. |
public boolean containsOrOwns(int x, int y) | Checks to see if this component either contains the given point, or if it owns the component that contains the given point. |
public void addFocusListener(FocusListener l) | Registers interest in receiving callbacks for focus gained events, a focus event is invoked when the component accepts the focus. |
public void removeFocusListener(FocusListener l) | Deregisters interest in receiving callbacks for focus gained events |
public void addScrollListener(ScrollListener l) | Registers interest in receiving callbacks for scroll gained events, a scroll event is invoked when the component is scrolled. |
public void removeScrollListener(ScrollListener l) | Deregisters interest in receiving callbacks for scroll gained events |
protected void fireClicked() | When working in 3 softbutton mode “fire” key (center softbutton) is sent to this method in order to allow 3 button devices to work properly. |
protected boolean isSelectableInteraction() | This method allows a component to indicate that it is interested in an “implicit” select command to appear in the “fire” button when 3 softbuttons are defined in a device. |
public String getSelectCommandText() | Allows determining the text for the select command used in the 3rd softbutton mode. |
public void setSelectCommandText(String selectText) | Allows determining the text for the select command used in the 3rd softbutton mode. |
public Label getLabelForComponent() | Allows us to indicate the label associated with this component thus providing visual feedback related for this component e.g. starting the ticker when the component receives focus. |
public void setLabelForComponent(Label componentLabel) | Allows us to indicate the label associated with this component thus providing visual feedback related for this component e.g. starting the ticker when the component receives focus. |
protected void focusGained() | Callback allowing a developer to track when the component gains focus |
protected void focusLost() | Callback allowing a developer to track wheh the component loses focus |
public void paintBackgrounds(Graphics g) | This method paints all the parents Components Background. |
public void paintShadows(Graphics g, int relativeX, int relativeY) | Paints the drop-shadow projections for this component based on its elevation value. |
public int getAbsoluteX() | Returns the absolute X location based on the component hierarchy, this method calculates a location on the screen for the component rather than a relative location as returned by getX() |
public int getAbsoluteY() | Returns the absolute Y location based on the component hierarchy, this method calculates a location on the screen for the component rather than a relative location as returned by getX() |
protected boolean isInClippingRegion(Graphics g) | |
public void paintIntersectingComponentsAbove(Graphics g) | Deprecated Paints intersecting components that appear above this component. |
protected void paintScrollbars(Graphics g) | Paints the UI for the scrollbars on the component, this will be invoked only for scrollable components. |
protected void paintScrollbarX(Graphics g) | Paints the UI for the scrollbar on the X axis, this method allows component subclasses to customize the look of a scrollbar |
public int getScrollOpacity() | This method is used internally by the look and feel to implement the fading scrollbar behavior. |
public Rectangle getSelectedRect() | Returns the component bounds with absolute screen coordinates, for components that include an internal selection behavior and are not containers (currently only List) this method allows returning the position of the selection itself which i… |
protected void paintScrollbarY(Graphics g) | Paints the UI for the scrollbar on the Y axis, this method allows component subclasses to customize the look of a scrollbar |
public final void paintComponent(Graphics g) | Paints this component as a root by going to all the parent components and setting the absolute translation based on coordinates and scroll status. |
public final void paintComponent(Graphics g, boolean background) | Paints this component as a root by going to all the parent components and setting the absolute translation based on coordinates and scroll status. |
protected Border getBorder() | Normally returns getStyle().getBorder() but some subclasses might use this to programmatically replace the border in runtime e.g. for a pressed border effect |
public Component getScrollable() | Returns the scrollable parent of this component |
protected void paintBackground(Graphics g) | This method paints the Component background, it should be overriden by subclasses to perform custom background drawing. |
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. |
protected boolean isScrollable() | Indicates whether the component should/could scroll by default a component is not scrollable. |
public boolean isScrollableX() | Indicates 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 int getScrollX() | Indicates the X position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the x position of the component. |
protected void setScrollX(int scrollX) | Indicates the X position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the x position of the component. |
public int getScrollY() | Indicates the Y position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the y position of the component. |
protected void setScrollY(int scrollY) | Indicates the Y position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the y position of the component. |
protected void onScrollX(int scrollX) | This method can be overriden to receive scroll events, unlike overriding setScrollX it will receive all calls for scrolling. |
protected void onScrollY(int scrollY) | This method can be overriden to receive scroll events, unlike overriding setScrollY it will receive all calls for scrolling. |
public int getDraggedx() | Gets the current dragged x values when the Component is being dragged |
public int getDraggedy() | Gets the current dragged y values when the Component is being dragged |
public int getBottomGap() | Returns the gap to be left for the bottom scrollbar on the X axis. |
public int getSideGap() | Returns the gap to be left for the side scrollbar on the Y axis. |
public boolean contains(int x, int y) | Returns true if the given absolute coordinate is contained in the Component |
public boolean visibleBoundsContains(int x, int y) | Returns true if the given absolute coordinate is contained inside the visible bounds of the component. |
protected Dimension calcPreferredSize() | Calculates the preferred size based on component content. |
public boolean hasFixedPreferredSize() | Checks if this component has a fixed preferred size either via an explicit call to #setPreferredH(int) and #setPreferredW(int), or via a preferred size style string. |
protected Rectangle getBounds() | Returns the component bounds which is sometimes more convenient than invoking getX/Y/Width/Height. |
public Rectangle getBounds(Rectangle rect) | Returns the bounds of this component in the provided Rectangle. |
protected Rectangle getVisibleBounds() | Returns the component bounds for scrolling which might differ from the getBounds for large components e.g. list. |
public Rectangle getVisibleBounds(Rectangle rect) | Returns the component bounds for scrolling which might differ from the getBounds for large components into the provided rectangle. |
public boolean isFocusable() | Returns true if this component can receive focus and is enabled |
public final void setFocusable(boolean focusable) | A simple setter to determine if this Component can get focused |
protected void onSetFocusable(boolean focusable) | Since setFocusable is final this callback is invoked when focusable changes. |
protected void resetFocusable() | Restores the state of the focusable flag to its default state |
public int getTabIndex() | Deprecated Gets the tab index of the component. |
public void setTabIndex(int index) | Deprecated Sets the tab index of the component. |
public int getPreferredTabIndex() | Gets the preferred tab index of this component. |
public void setPreferredTabIndex(int index) | Sets the preferred tab index of the component. |
public final boolean isTraversable() | Checks if this component should be traversable using the keyboard using tab, next, previous keys. |
public final void setTraversable(boolean traversable) | Sets whether this component is traversable using the keyboard using tab, next, previous keys. |
public void setShouldCalcPreferredSize(boolean shouldCalcPreferredSize) | Indicates the values within the component have changed and preferred size should be recalculated |
public boolean handlesInput() | Prevents key events from being grabbed for focus traversal. |
public void setHandlesInput(boolean handlesInput) | Prevents key events from being grabbed for focus traversal. |
protected boolean consumesRawTextInput() | Whether this component turns key codes into printable characters, as a text editor does. |
public boolean hasFocus() | Returns true if the component has focus |
public void setFocus(boolean focused) | Deprecated This flag doesn’t really give focus, its a state that determines what colors from the Style should be used when painting the component. |
public 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 void repaint() | Repaint this Component, the repaint call causes a callback of the paint method on the event dispatch thread. |
public void repaint(int x, int y, int w, int h) | Repaints a specific region within the component |
protected void longKeyPress(int keyCode) | If this Component is focused this method is invoked when the user presses and holds the key |
public void keyPressed(int keyCode) | If this Component is focused, the key pressed event will call this method |
public void keyReleased(int keyCode) | If this Component is focused, the key released event will call this method |
public void keyRepeated(int keyCode) | If this Component is focused, the key repeat event will call this method. |
protected void registerForAnimation() | Registers this component to be animated by the top level it currently sits in. |
protected void deregisterFromAnimation() | Stops this component being animated, by the top level it registered with rather than whichever one it can resolve now. |
public AnimationManager getAnimationManager() | |
public int getScrollAnimationSpeed() | Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode |
public void setScrollAnimationSpeed(int animationSpeed) | Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode |
public boolean isBlockLead() | Prevent a lead component hierarchy from this specific component, this allows a component within that hierarchy to still act as a standalone component |
public void setBlockLead(boolean blockLead) | Prevent a lead component hierarchy from this specific component, this allows a component within that hierarchy to still act as a standalone component |
public boolean isIgnorePointerEvents() | |
public void setIgnorePointerEvents(boolean ignorePointerEvents) | |
public boolean isRippleEffect() | Indicates whether the component displays the material design ripple effect |
public void setRippleEffect(boolean rippleEffect) | Indicates whether the component displays the material design ripple effect |
public Resources getInlineStylesTheme() | Gets the theme that is used by inline styles to reference images. |
public void setInlineStylesTheme(Resources inlineStylesTheme) | Sets the theme that is used by inline styles to reference images. |
protected boolean shouldRenderComponentSelection() | A component can indicate whether it is interested in rendering it’s selection explicitly, this defaults to true in non-touch UI’s and false in touch UI’s except for the case where a user clicks the screen. |
public boolean isHideInLandscape() | Indicates that this component and all its children should be hidden when the device is switched to landscape mode |
public void setHideInLandscape(boolean hideInLandscape) | Indicates that this component and all its children should be hidden when the device is switched to landscape mode |
public ComponentAnimation createStyleAnimation(String destUIID, int duration) | Creates an animation that will transform the current component to the styling of the destination UIID when completed. |
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 void pointerHover(int[] x, int[] y) | Invoked for devices where the pointer can hover without actually clicking the display. |
public void stopScrollMomentum() | Stops any momentum or tensile scroll animation currently running on this component, leaving the scroll position exactly where it is. |
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. |
protected boolean pinch(float scale) | Invoked by subclasses interested in handling pinch to zoom events, if true is returned other drag events will not be broadcast |
protected void pinchReleased(int x, int y) | To be implemented by subclasses interested in being notified when a pinch zoom has ended (i.e the user has removed one of their fingers, but is still dragging). |
protected boolean pinch(int[] x, int[] y) | Invoked by subclasses interested in handling pinch to do their own actions based on the position of the two fingers, if true is returned other drag events will not be broadcast |
protected boolean rotation(float radians) | Invoked when a rotation (twist) gesture occurs over this component, such as a two finger trackpad rotation on macOS or a two finger rotate on a touch screen. |
public boolean isPinchBlocksDragAndDrop() | returns true if pinch will block drag and drop |
public void setPinchBlocksDragAndDrop(boolean block) | If a component supports pinch as well as drag and drop the two may conflict (if one finger is placed a bit before the other, the drag timer will be initiated and may trigger drag even if the second finger has been placed before). |
public void pointerDragged(int[] x, int[] y) | If this Component is focused, the pointer dragged event will call this method |
protected Image getDragImage() | This method returns an image representing the dragged component, it can be overriden by subclasses to customize the look of the image, the image will be overlaid on top of the form during a drag and drop operation |
public byte getDragTransparency() | Returns the translucency used in the #getDragImage() method. |
public void setDragTransparency(byte dragTransparency) | Sets the translucency of the #getDragImage() method. |
public Image toImage() | Returns the component as an image. |
protected void dragInitiated() | Invoked on the focus component to let it know that drag has started on the parent container for the case of a component that doesn’t support scrolling |
protected void drawDraggedImage(Graphics g, Image img, int x, int y) | Draws the given image at x/y, this method can be overriden to draw additional information such as positive or negative drop indication |
protected boolean draggingOver(Component dragged, int x, int y) | This method allows a component to indicate if it is a drop target for the given component at the given x/y location (in component coordiate space). |
protected void dragEnter(Component dragged) | This callback method indicates that a component drag has just entered this component |
protected void dragExit(Component dragged) | This callback method provides an indication for a drop target that a drag operation is exiting the bounds of this component and it should clear all relevant state if such state exists. |
public void drop(Component dragged, int x, int y) | Performs a drop operation of the component at the given X/Y location in coordinate space, this method should be overriden by subclasses to perform all of the logic related to moving a component, by default this method does nothing and so dr… |
public void addPullToRefresh(Runnable task) | This method adds a refresh task to the Component, the task will be executed if the user has pulled the scroll beyond a certain height. |
public void setPullToRefresh(Runnable task) | Alias for #addPullToRefresh(Runnable) – both names point at the same single-task slot, and a second call replaces the previously-registered runnable. |
public boolean respondsToPointerEvents() | Checks if the component responds to pointer events. |
public void pointerDragged(int x, int y) | If this Component is focused, the pointer dragged event will call this method |
protected boolean isStickyDrag() | Returns true if the component is interested in receiving drag/pointer release events even after the gesture exceeded its boundaries. |
public void pointerPressed(int[] x, int[] y) | If this Component is focused, the pointer pressed event will call this method |
protected boolean isDragAndDropOperation(int x, int y) | This method allows a developer to define only a specific portion of a component as draggable by default it returns true if the component is defined as “draggable” |
public void pointerPressed(int x, int y) | If this Component is focused, the pointer pressed event will call this method |
public void pointerReleased(int[] x, int[] y) | If this Component is focused, the pointer released event will call this method |
public void longPointerPress(int x, int y) | If this Component is focused this method is invoked when the user presses and holds the pointer on the Component |
public void pointerReleased(int x, int y) | If this Component is focused, the pointer released event will call this method |
public void setVerticalScrollBounds(int thumbX, int thumbY, int thumbW, int thumbH, int trackX, int trackY, int trackW, int trackH) | Records the painted geometry of the vertical interactive scrollbar so the pointer handling code can hit-test the thumb and track. |
public void setHorizontalScrollBounds(int thumbX, int thumbY, int thumbW, int thumbH, int trackX, int trackY, int trackW, int trackH) | Records the painted geometry of the horizontal interactive scrollbar. |
public boolean isVScrollThumbGrabbed() | Indicates whether the vertical interactive scrollbar thumb is currently grabbed/dragged. |
public boolean isHScrollThumbGrabbed() | Indicates whether the horizontal interactive scrollbar thumb is currently grabbed/dragged. |
public boolean isVScrollThumbHover() | Indicates whether the pointer hovers the vertical interactive scrollbar thumb. |
public boolean isHScrollThumbHover() | Indicates whether the pointer hovers the horizontal interactive scrollbar thumb. |
public boolean isTensileDragEnabled() | Indicates whether tensile drag (dragging beyond the boundry of the component and snapping back) is enabled for this component. |
public void setTensileDragEnabled(boolean tensileDragEnabled) | Indicates whether tensile drag (dragging beyond the boundry of the component and snapping back) is enabled for this component. |
public TextSelection.TextSelectionSupport getTextSelectionSupport() | Returns text selection support object for this component. |
public void addDropListener(ActionListener l) | Binds an action listener to drop events which are invoked when this component is dropped on a target |
public void removeDropListener(ActionListener l) | Removes an action listener to drop events which are invoked when this component is dropped on a target |
public void addDragOverListener(ActionListener l) | Broadcasts an event when dragging over a component |
public void removeDragOverListener(ActionListener l) | Removes an action listener to drag over events |
public boolean isNativeDragSource() | Returns true when a drag starting on this component is handed to the operating system. |
public void setNativeDragSource(boolean nativeDragSource) | Makes a drag that starts on this component an operating system drag, which can be dropped outside the application. |
public NativeDragOperation getNativeDragOperation() | Returns the operation this component drags, or null when it supplies one per press by overriding #createNativeDragOperation(int, int). |
public void setNativeDragOperation(NativeDragOperation nativeDragOperation) | Sets what dragging this component puts on the operating system’s drag, and makes the component a native drag source. |
protected NativeDragOperation createNativeDragOperation(int x, int y) | Produces the operation for a drag starting at the given position, invoked on the event dispatch thread as the press is dispatched. |
public boolean isNativeDropTarget() | Returns true when this component accepts drops coming from the operating system. |
public void setNativeDropTarget(boolean nativeDropTarget) | Lets this component receive drops from the operating system: from another application, from a file manager, from the desktop, or from elsewhere in this application. |
public String[] getAcceptedDropMimeTypes() | Returns the MIME types this component accepts, or null when it accepts anything. |
public void setAcceptedDropMimeTypes(String... acceptedDropMimeTypes) | Restricts the drops this component accepts to drags offering at least one of these MIME types, so a drag carrying anything else passes through to whatever is behind it. |
public int getAcceptedDropActions() | Returns the bit set of actions this component is willing to perform on a drop. |
public void setAcceptedDropActions(int acceptedDropActions) | Restricts what this component will do with a drop – a target that can only copy should not be offered a move, because the source deletes its data when a move completes. |
protected boolean canAcceptNativeDrop(ClipboardContent content) | Decides whether this component wants a drag carrying these representations at all. |
protected void nativeDragEnter(NativeDropEvent ev) | Callback invoked on the event dispatch thread when a native drag enters this component. |
protected void nativeDragOver(NativeDropEvent ev) | Callback invoked on the event dispatch thread as a native drag moves over this component. |
protected void nativeDragExit(NativeDropEvent ev) | Callback invoked on the event dispatch thread when a native drag leaves this component without dropping. |
protected void nativeDrop(NativeDropEvent ev) | Callback invoked on the event dispatch thread when a native drag is dropped on this component. |
public void addNativeDropListener(ActionListener l) | Adds a listener invoked on the event dispatch thread when a native drag is dropped on this component. |
public void removeNativeDropListener(ActionListener l) | Removes a listener added by #addNativeDropListener(com.codename1.ui.events.ActionListener). |
public void addNativeDragOverListener(ActionListener l) | Adds a listener invoked on the event dispatch thread as a native drag enters, moves over and leaves this component. |
public void removeNativeDragOverListener(ActionListener l) | Removes a listener added by #addNativeDragOverListener(com.codename1.ui.events.ActionListener). |
protected void dragFinished(int x, int y) | Callback indicating that the drag has finished either via drop or by releasing the component |
public void addDragFinishedListener(ActionListener l) | Adds a listener to the dragFinished event |
public void addStateChangeListener(ActionListener<ComponentStateChangeEvent> l) | Adds a listener to be notified when the state of this component is changed to and from initialized. |
public void removeStateChangeListener(ActionListener<ComponentStateChangeEvent> l) | Removes a listener from being notified when the state of this component is changed to and from initialized. |
public void addPointerPressedListener(ActionListener l) | Adds a listener to the pointer event |
public void addLongPressListener(ActionListener l) | Adds a listener to the pointer event |
public void addContextMenuListener(ActionListener l) | Adds a listener that is notified when the user requests a context menu on this component. |
public void removeContextMenuListener(ActionListener l) | Removes a context menu listener. |
public void addMouseWheelListener(ActionListener l) | Adds a listener that is notified when the mouse wheel (or a trackpad scroll gesture) is moved while the pointer is over this component. |
public void removeMouseWheelListener(ActionListener l) | Removes a mouse wheel listener. |
public void addStylusListener(ActionListener l) | Adds a listener that is notified for stylus and pen interactions (Apple Pencil, S-Pen, Surface Pen and similar) on this component. |
public void removeStylusListener(ActionListener l) | Removes a stylus listener. |
protected boolean mouseWheel(WheelEvent ev) | Handles a scroll wheel or trackpad scroll over this component, before its listeners and before anything above it in the hierarchy. |
public void paintRippleOverlay(Graphics g, int x, int y, int position) | Invoked to draw the ripple effect overlay in Android where the finger of the user causes a growing circular overlay over time. |
public void removePointerPressedListener(ActionListener l) | Removes the listener from the pointer event |
public void removeLongPressListener(ActionListener l) | Removes the listener from the pointer event |
public void removeDragFinishedListener(ActionListener l) | Removes the listener from the drag finished 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 addPointerDraggedListener(ActionListener l) | Adds a listener to the pointer event |
public void removePointerDraggedListener(ActionListener l) | Removes the listener from the pointer event |
protected float getDragSpeed(boolean vertical) | This method returns the dragging speed based on the latest dragged events |
public Style getStyle() | Returns the current Component Style allowing code to draw the current component, you should normally use getUnselected/Pressed/DisabledStyle() and not this method since it will return different values based on component state. |
public Style getPressedStyle() | Returns the Component Style for the pressed state allowing us to manipulate the look of the component when it is pressed |
public void setPressedStyle(Style style) | Sets the Component Style for the pressed state allowing us to manipulate the look of the component when it is pressed |
protected void initUnselectedStyle(Style unselectedStyle) | Can be overridden by subclasses to perform initialization when the unselected style is set to a new value. |
protected void initPressedStyle(Style pressedStyle) | Can be overridden by subclasses to perform initialization when the pressed style is set to a new value. |
protected void initDisabledStyle(Style disabledStyle) | Can be overridden by subclasses to perform initialization when the disabled style is set to a new value. |
protected void initSelectedStyle(Style selectedStyle) | Can be overridden by subclasses to perform initialization when the selected style is set to a new value. |
public final Style getUnselectedStyle() | Returns the Component Style for the unselected mode allowing us to manipulate the look of the component |
public void setUnselectedStyle(Style style) | Changes the Component Style by replacing the Component Style with the given Style |
public Style getSelectedStyle() | Returns the Component Style for the selected state allowing us to manipulate the look of the component when it owns focus |
public void setSelectedStyle(Style style) | Changes the Component selected Style by replacing the Component Style with the given Style |
public Style getDisabledStyle() | Returns the Component Style for the disabled state allowing us to manipulate the look of the component when its disabled |
public void setDisabledStyle(Style style) | Changes the Component disalbed Style by replacing the Component Style with the given Style |
protected void installDefaultPainter(Style s) | Allows subclasses to create their own custom style types and install the background painter into them |
public void requestFocus() | Changes the current component to the focused component, will work only for a component that belongs to a parent form. |
public String toString() | Overriden to return a useful value for debugging purposes |
protected String paramString() | Returns a string representing the state of this component. |
public void refreshTheme() | Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME! |
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! |
protected void refreshTheme(String id, boolean merge) | Makes sure the component is up to date with the given UIID |
protected boolean isDragActivated() | Indicates whether we are in the middle of a drag operation, this method allows developers overriding the pointer released events to know when this is a drag operation. |
protected int getGridPosY() | This method should be implemented correctly by subclasses to make snap to grid functionality work as expected. |
protected int getGridPosX() | This method should be implemented correctly by subclasses to make snap to grid functionality work as expected. |
public boolean animate() | Allows the animation to reduce “repaint” calls when it returns false. |
protected void scrollRectToVisible(Rectangle rect, Component coordinateSpace) | Makes sure the component is visible in the scroll if this container is scrollable |
public void scrollRectToVisible(int x, int y, int width, int height, Component coordinateSpace) | Makes sure the component is visible in the scroll if this container is scrollable |
protected void paintBorder(Graphics g) | Draws the component border if such a border exists. |
protected void paintBorderBackground(Graphics g) | Draws the component border background if such a border exists. |
public boolean isCellRenderer() | Used as an optimization to mark that this component is currently being used as a cell renderer |
public void setCellRenderer(boolean cellRenderer) | Used as an optimization to mark that this component is currently being used as a cell renderer |
public boolean isScrollVisible() | Indicate whether this component scroll is visible |
public void setScrollVisible(boolean isScrollVisible) | Set whether this component scroll is visible |
public void setIsScrollVisible(boolean isScrollVisible) | Deprecated Set whether this component scroll is visible |
public void startEditingAsync() | If the component #isEditable(), then this will start the editing process. |
public void stopEditing(Runnable onFinish) | Stops the editing process. |
public boolean isEditing() | Checks if the component is currently being edited. |
public boolean isEditable() | Checks to see if the component is editable. |
protected void laidOut() | This is a callback method to inform the Component when it’s been laidout on the parent Container |
protected void deinitialize() | Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. |
protected void initComponent() | Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state |
protected boolean isInitialized() | Indicates if the component is in the initialized state, a component is initialized when its initComponent() method was invoked. |
protected void setInitialized(boolean initialized) | Indicates if the component is in the initialized state, a component is initialized when its initComponent() method was invoked. |
public void styleChanged(String propertyName, Style source) | Invoked to indicate a change in a propertyName of a Style |
public Component getNextFocusDown() | Allows us to determine which component will receive focus next when traversing with the down key |
public void setNextFocusDown(Component nextFocusDown) | Allows us to determine which component will receive focus next when traversing with the down key |
public Component getNextFocusUp() | Allows us to determine which component will receive focus next when traversing with the up key. |
public void setNextFocusUp(Component nextFocusUp) | Allows us to determine which component will receive focus next when traversing with the up key, this method doesn’t affect the general focus behavior. |
public Component getNextFocusLeft() | Allows us to determine which component will receive focus next when traversing with the left key. |
public void setNextFocusLeft(Component nextFocusLeft) | Allows us to determine which component will receive focus next when traversing with the left key, this method doesn’t affect the general focus behavior. |
public Component getNextFocusRight() | Allows us to determine which component will receive focus next when traversing with the right key |
public void setNextFocusRight(Component nextFocusRight) | Allows us to determine which component will receive focus next when traversing with the right key |
public boolean isEnabled() | Indicates whether component is enabled or disabled thus allowing us to prevent a component from receiving input events and indicate so visually |
public void setEnabled(boolean enabled) | Indicates whether component is enabled or disabled thus allowing us to prevent a component from receiving input events and indicate so visually |
public String getName() | A component name allows us to easily identify the component within a dynamic UI. |
public void setName(String name) | A component name allows us to easily identify the component within a dynamic UI. |
protected void initCustomStyle(Style s) | Allows components to create a style of their own, this method binds the listener to the style and installs a bg painter |
protected void deinitializeCustomStyle(Style s) | Allows components to create a style of their own, this method cleans up state for the given style |
public final boolean isRTL() | Is the component a bidi RTL component |
public void setRTL(boolean rtl) | Is the component a bidi RTL component |
protected boolean isTactileTouch(int x, int y) | Elaborate components might not provide tactile feedback for all their areas (e.g. Lists) this method defaults to returning the value of isTactileTouch |
public boolean isTactileTouch() | Indicates whether the component should “trigger” tactile touch when pressed by the user in a touch screen UI. |
public void setTactileTouch(boolean tactileTouch) | Indicates whether the component should “trigger” tactile touch when pressed by the user in a touch screen UI. |
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 void paintLockRelease() | Releases the paint lock image to allow paint to work as usual, see paintLock(boolean) for details |
public Image paintLock(boolean hardLock) | This method locks the component so it will always paint the given image instead of running through its paint logic. |
public boolean isSnapToGrid() | Indicates whether scrolling this component should jump to a specific location in a grid |
public void setSnapToGrid(boolean snapToGrid) | Deprecated Indicates whether scrolling this component should jump to a specific location in a grid |
protected boolean shouldBlockSideSwipe() | A component that might need side swipe such as the slider could block it from being used for some other purpose when on top of said component. |
protected boolean shouldBlockSideSwipeLeft() | A component that might need side swipe such as the tabs could block it from being used for some other purpose when on top of said component. |
protected boolean shouldBlockSideSwipeRight() | A component that might need side swipe such as the tabs could block it from being used for some other purpose when on top of said component. |
public final boolean blocksSideSwipe() | A component that might need side swipe such as the slider could block it from being used for some other purpose when on top of said component. |
public boolean isFlatten() | Makes the component effectively opaque by blending the backgrounds into an image in memory so the layer of underlying components is only drawn once when this component is repainted. |
public void setFlatten(boolean flatten) | Makes the component effectively opaque by blending the backgrounds into an image in memory so the layer of underlying components is only drawn once when this component is repainted. |
public int getTensileLength() | Recommended length for the tensile, -1 for default |
public void setTensileLength(int tensileLength) | Recommended length for the tensile, -1 for default |
public boolean isGrabsPointerEvents() | This property is useful for blocking in z-order touch events, sometimes we might want to grab touch events in a specific component without making it focusable. |
public void setGrabsPointerEvents(boolean grabsPointerEvents) | This property is useful for blocking in z-order touch events, sometimes we might want to grab touch events in a specific component without making it focusable. |
public int getScrollOpacityChangeSpeed() | Indicates the decrement units for the scroll opacity |
public void setScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed) | Indicates the decrement units for the scroll opacity |
public void growShrink(int duration) | Grows or shrinks this component to its new preferred size, this method essentially takes a component whose preferred size has changed and creates a “growing” effect that lasts for the duration. |
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 isDraggable() | Indicates whether this component can be dragged in a drag and drop operation rather than scroll the parent |
public void setDraggable(boolean draggable) | Indicates whether this component can be dragged in a drag and drop operation rather than scroll the parent |
public boolean isDropTarget() | Indicates whether this component can receive dropped components into it, notice that when dropping on a component or container the parents will be checked recursively to find a valid drop target |
public void setDropTarget(boolean dropTarget) | Indicates whether this component can receive dropped components into it, notice that when dropping on a component or container the parents will be checked recursively to find a valid drop target |
public boolean isChildOf(Container cnt) | Searches the hierarchy of the component recursively to see if the given Container is one of the parents of this component |
public boolean isHideInPortrait() | Indicates that this component and all its children should be hidden when the device is switched to portrait mode |
public void setHideInPortrait(boolean hideInPortrait) | Indicates that this component and all its children should be hidden when the device is switched to portrait mode |
protected void cancelRepaints() | remove this component from the painting queue |
public String[] getBindablePropertyNames() | Deprecated Returns the names of the properties within this component that can be bound for persistence, the order of these names mean that the first one will be the first bound |
public Class[] getBindablePropertyTypes() | Deprecated Returns the types of the properties that are bindable within this component |
public void bindProperty(String prop, BindTarget target) | Deprecated Binds the given property name to the given bind target |
public void unbindProperty(String prop, BindTarget target) | Deprecated Removes a bind target from the given property name |
public Object getBoundPropertyValue(String prop) | Deprecated Allows the binding code to extract the value of the property |
public void setBoundPropertyValue(String prop, Object value) | Deprecated Sets the value of a bound property within this component, notice that this method MUST NOT fire the property change event when invoked to prevent recursion! |
public String getCloudBoundProperty() | Deprecated Indicates the property within this component that should be bound to the cloud object |
public void setCloudBoundProperty(String cloudBoundProperty) | Deprecated Indicates the property within this component that should be bound to the cloud object |
public String getCloudDestinationProperty() | Deprecated The destination property of the CloudObject |
public void setCloudDestinationProperty(String cloudDestinationProperty) | Deprecated The destination property of the CloudObject |
public Object getComponentState() | Some components may optionally generate a state which can then be restored using setCompnentState(). |
public void setComponentState(Object state) | If getComponentState returned a value the setter can update the value and restore the prior state. |
public void setHidden(boolean b, boolean changeMargin) | Makes the components preferred size equal 0 when hidden and restores it to the default size when not. |
public boolean isHidden() | Returns true if the component was explicitly hidden by the user. |
public void setHidden(boolean b) | Makes the components preferred size equal 0 when hidden and restores it to the default size when not. |
public boolean isHidden(boolean checkParent) | Checks if the component is hidden. |
public void announceForAccessibility(String text) | Manually announces text to native accessibility services, associating the announcement with this component when possible. |
public String getAccessibilityText() | Returns the text that describes this component to assistive technologies. |
public void setAccessibilityText(String text) | Sets the text that describes this component to assistive technologies. |
public AccessibilityNode getSemantics() | Returns the portable semantic configuration for this component. |
public AccessibilityNode getAccessibilityNode() | Alias for getSemantics() for APIs that use accessibility-node terminology. |
public void accessibilityChanged() | Marks this component’s semantic representation dirty. |
public void accessibilityChanged(int changeType) | Marks a specific portion of this component’s semantic representation dirty. |
public String getTooltip() | |
public void setTooltip(String tooltip) |
Inherited methods
Field details
DEFAULT_CURSOR
public static final int DEFAULT_CURSOR = 0CROSSHAIR_CURSOR
public static final int CROSSHAIR_CURSOR = 1TEXT_CURSOR
public static final int TEXT_CURSOR = 2WAIT_CURSOR
public static final int WAIT_CURSOR = 3SW_RESIZE_CURSOR
public static final int SW_RESIZE_CURSOR = 4SE_RESIZE_CURSOR
public static final int SE_RESIZE_CURSOR = 5NW_RESIZE_CURSOR
public static final int NW_RESIZE_CURSOR = 6NE_RESIZE_CURSOR
public static final int NE_RESIZE_CURSOR = 7N_RESIZE_CURSOR
public static final int N_RESIZE_CURSOR = 8S_RESIZE_CURSOR
public static final int S_RESIZE_CURSOR = 9W_RESIZE_CURSOR
public static final int W_RESIZE_CURSOR = 10E_RESIZE_CURSOR
public static final int E_RESIZE_CURSOR = 11HAND_CURSOR
public static final int HAND_CURSOR = 12MOVE_CURSOR
public static final int MOVE_CURSOR = 13DRAG_REGION_NOT_DRAGGABLE
public static final int DRAG_REGION_NOT_DRAGGABLE = 1DRAG_REGION_POSSIBLE_DRAG_X
public static final int DRAG_REGION_POSSIBLE_DRAG_X = 10DRAG_REGION_POSSIBLE_DRAG_Y
public static final int DRAG_REGION_POSSIBLE_DRAG_Y = 11DRAG_REGION_POSSIBLE_DRAG_XY
public static final int DRAG_REGION_POSSIBLE_DRAG_XY = 12DRAG_REGION_LIKELY_DRAG_X
public static final int DRAG_REGION_LIKELY_DRAG_X = 21DRAG_REGION_LIKELY_DRAG_Y
public static final int DRAG_REGION_LIKELY_DRAG_Y = 22DRAG_REGION_LIKELY_DRAG_XY
public static final int DRAG_REGION_LIKELY_DRAG_XY = 23DRAG_REGION_IMMEDIATELY_DRAG_X
public static final int DRAG_REGION_IMMEDIATELY_DRAG_X = 31DRAG_REGION_IMMEDIATELY_DRAG_Y
public static final int DRAG_REGION_IMMEDIATELY_DRAG_Y = 32DRAG_REGION_IMMEDIATELY_DRAG_XY
public static final int DRAG_REGION_IMMEDIATELY_DRAG_XY = 33BRB_CONSTANT_ASCENT
public static final int BRB_CONSTANT_ASCENT = 1See also
BRB_CONSTANT_DESCENT
public static final int BRB_CONSTANT_DESCENT = 2See also
BRB_CENTER_OFFSET
public static final int BRB_CENTER_OFFSET = 3See also
BRB_OTHER
public static final int BRB_OTHER = 4See also
CENTER
public static final int CENTER = 4TOP
public static final int TOP = 0LEFT
public static final int LEFT = 1BOTTOM
public static final int BOTTOM = 2RIGHT
public static final int RIGHT = 3BASELINE
public static final int BASELINE = 5Constructor details
Component
protected Component()Method details
setSameSize
public static void setSameSize(Component... c)#sameWidth followed by #sameHeightParameters
cComponent...- the components to group together, this will override all previous width/height grouping
isSetCursorSupported
public static boolean isSetCursorSupported()#setCursor(int) will simply be ignored.Returns
parsePreferredSize
public static Dimension parsePreferredSize(String preferredSize, Dimension baseSize)Parameters
preferredSizeString- a string representing a width/height preferred size using common units e.g. mm, px etc.
baseSizeDimension- used as the starting point for the calculation, typically the preferred size of the component
Returns
getDefaultDragTransparency
public static byte getDefaultDragTransparency()#getDragImage() method.Returns
setDefaultDragTransparency
public static void setDefaultDragTransparency(byte defaultDragTransparency)#getDragImage() method.Parameters
defaultDragTransparencybyte- a number between 0 and 255 where 255 indicates an opaque image.
getEditingDelegate
public Editable getEditingDelegate()Returns
setEditingDelegate
public void setEditingDelegate(Editable editable)#isEditable(), #isEditing(), #startEditingAsync(), and #stopEditing(java.lang.Runnable)
will be delegated to the delegate object.Parameters
editableEditable- An editable delegate.
getCursor
public int getCursor()#isSetCursorSupported() to find out.Returns
#DEFAULT_CURSOR, #CROSSHAIR_CURSOR, #TEXT_CURSOR,
#WAIT_CURSOR, #SW_RESIZE_CURSOR, #SE_RESIZE_CURSOR, #S_RESIZE_CURSOR, #NE_RESIZE_CURSOR,
#NW_RESIZE_CURSOR, #W_RESIZE_CURSOR, #HAND_CURSOR, or #MOVE_CURSOR.setCursor
public void setCursor(int cursor)Sets a custom mouse cursor for this component if the platform supports mouse cursors, notice that this isn’t applicable for touch devices.
This will only be used if the platform supports custom cursors.
You can call #isSetCursorSupported() to find out.
Note: Since cursors incur some overhead, they are turned off at the form level by default.
If you want your custom cursors to be used, then you’ll need to enable cursors in the form using Form#setEnableCursors(boolean).
Parameters
cursorint- The cursor to set on this component. One of
#DEFAULT_CURSOR,#CROSSHAIR_CURSOR,#TEXT_CURSOR,#WAIT_CURSOR,#SW_RESIZE_CURSOR,#SE_RESIZE_CURSOR,#S_RESIZE_CURSOR,#NE_RESIZE_CURSOR,#NW_RESIZE_CURSOR,#W_RESIZE_CURSOR,#HAND_CURSOR, or#MOVE_CURSOR.
showNativeOverlay
protected void showNativeOverlay()hideNativeOverlay
protected void hideNativeOverlay()updateNativeOverlay
protected void updateNativeOverlay()getNativeOverlay
public Object getNativeOverlay()Returns
getAllStyles
public final Style getAllStyles()Returns a “meta style” that allows setting styles once to all the different Style objects, the getters for this style will be meaningless and will return 0 values. Usage:
Form hi = new Form("Painter via getAllStyles", new BorderLayout());
Container cmp = new Container();
cmp.setPreferredSize(new Dimension(300, 300));
Painter p = new Painter() {
public void paint(Graphics g, Rectangle rect) {
boolean antiAliased = g.isAntiAliased();
g.setAntiAliased(true);
int r = Math.min(rect.getWidth(), rect.getHeight()) / 2;
int x = rect.getX() + rect.getWidth() / 2 - r;
int y = rect.getY() + rect.getHeight() / 2 - r;
g.setColor(cmp.getStyle().getBgColor());
g.fillArc(x, y, 2 * r, 2 * r, 0, 360);
g.setColor(cmp.getStyle().getFgColor());
g.drawArc(x, y, 2 * r - 1, 2 * r - 1, 0, 360);
g.setAntiAliased(antiAliased);
}
};
cmp.getAllStyles().setBgColor(0x4488ff);
cmp.getAllStyles().setBgTransparency(255);
cmp.getAllStyles().setFgColor(0xffffff);
cmp.getAllStyles().setBgPainter(p);
hi.add(BorderLayout.CENTER, cmp);
hi.show();
Returns
getSameWidth
public Component[] getSameWidth()Returns
setSameWidth
public static void setSameWidth(Component... c)Parameters
cComponent...- the components to group together, this will override all previous width grouping
getSameHeight
public Component[] getSameHeight()Returns
setSameHeight
public static void setSameHeight(Component... c)Parameters
cComponent...- the components to group together, this will override all previous height grouping
initLaf
protected void initLaf(UIManager uim)getUIManager
public UIManager getUIManager()Returns
getX
public int getX()Returns
setX
public void setX(int x)Parameters
xint- the current x coordinate of the components origin
getOuterX
public int getOuterX()x - leftMargin).Returns
getInnerX
public int getInnerX()x + leftPadding.Returns
getY
public int getY()Returns
setY
public void setY(int y)Parameters
yint- the current y coordinate of the components origin
getOuterY
public int getOuterY()y - leftMargin.Returns
getInnerY
public int getInnerY()y + leftPadding.Returns
isVisible
public boolean isVisible()Returns
setVisible
public void setVisible(boolean visible)Parameters
visibleboolean- true if component is visible; otherwise false
getClientProperty
public Object getClientProperty(String key)Parameters
keyString- the key used for putClientProperty
Returns
stripMarginAndPadding
public Component stripMarginAndPadding()Returns
See also
clearClientProperties
public void clearClientProperties()putClientProperty
public void putClientProperty(String key, Object value)Parameters
keyString- arbitrary key for the property
valueObject- the value assigned to the given client property
getDirtyRegion
public final Rectangle getDirtyRegion()Returns
setDirtyRegion
public final void setDirtyRegion(Rectangle dirty)Parameters
dirtyRectangle- the region that needs repainting or null for the whole component
isOpaque
public boolean isOpaque()Returns
setOpaque
public final void setOpaque(boolean opaque)Parameters
opaqueboolean- False to not paint the component’s background.
getWidth
public int getWidth()Returns
setWidth
public void setWidth(int width)Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly.
If a user wishes to affect the component size, setPreferredSize should be used.
Parameters
widthint- the width of the component
See also
getOuterWidth
public int getOuterWidth()Returns
getInnerWidth
public int getInnerWidth()Returns
getHeight
public int getHeight()Returns
setHeight
public void setHeight(int height)Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly.
If a user wishes to affect the component size, setPreferredSize should be used.
Parameters
heightint- the height of the component
See also
getOuterHeight
public int getOuterHeight()Returns
getInnerHeight
public int getInnerHeight()Returns
isDragRegion
protected boolean isDragRegion(int x, int y)Parameters
xint- x location for the touch
yint- y location for the touch
Returns
getDragRegionStatus
protected int getDragRegionStatus(int x, int y)Parameters
xint- x location for the touch
yint- y location for the touch
Returns
getBaseline
public int getBaseline(int width, int height)Parameters
widthint- the component width
heightint- the component height
Returns
getBaselineResizeBehavior
public int getBaselineResizeBehavior()Returns
getPreferredSizeStr
public String getPreferredSizeStr()#getPreferredSize() to find
the preferred size of a component.#calcPreferredSize().Returns
setPreferredSizeStr
public void setPreferredSizeStr(String value)Parameters
valueString- The preferred size to set in format “width height”, where width and height can be a scalar value with px or mm units. Or the special value “inherit” which will just inherit the default preferred size.
getPreferredSize
public Dimension getPreferredSize()Returns the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size. The final size of the component may be smaller than its preferred size or even larger than the size.
The Layout manager can take this value into consideration, but there is no guarantee or requirement.
Returns
setPreferredSize
public void setPreferredSize(Dimension d)Sets the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size. The final size of the component may be smaller than its preferred size or even larger than the size.
The Layout manager can take this value into consideration, but there is no guarantee or requirement.
Parameters
dDimension- the component dimension
getScrollDimension
public Dimension getScrollDimension()Returns
calcScrollSize
protected Dimension calcScrollSize()Returns
setScrollSize
public void setScrollSize(Dimension d)Parameters
dDimension- dimension of the scroll area
getPreferredW
public int getPreferredW()Returns
See also
setPreferredW
public void setPreferredW(int preferredW)Parameters
preferredWint- the preferred width of the component
See also
getPreferredH
public int getPreferredH()Returns
See also
setPreferredH
public void setPreferredH(int preferredH)Parameters
preferredHint- the preferred height of the component
See also
getOuterPreferredH
public int getOuterPreferredH()Returns
getInnerPreferredH
public int getInnerPreferredH()Returns
getOuterPreferredW
public int getOuterPreferredW()Returns
getInnerPreferredW
public int getInnerPreferredW()Returns
setSize
public void setSize(Dimension d)Sets the Component size, this method is exposed for the purpose of external layout managers and should not be invoked directly.
If a user wishes to affect the component size, setPreferredSize should be used.
Parameters
dDimension- the component dimension
See also
getUIID
public final String getUIID()Returns
setUIID
public void setUIID(String id)Parameters
idString- UIID unique identifier for component type
setUIIDFinal
protected final void setUIIDFinal(String id)Parameters
idString- UIID unique identifier for component type
setUIID
public void setUIID(String portraitUiid, String landscapeUiid)Parameters
portraitUiidString- UIID unique identifier for component type in portrait mode
landscapeUiidString- UIID unique identifier for component type in landscape mode
getInlineAllStyles
public String getInlineAllStyles()Returns
setInlineAllStyles
public void setInlineAllStyles(String styles)Parameters
stylesString- a style in the format of
"fgColor:ff0000; font:18mm; border: 1px solid ff0000; bgType:none; padding: 3mm; margin: 1mm"
getInlineSelectedStyles
public String getInlineSelectedStyles()Returns
setInlineSelectedStyles
public void setInlineSelectedStyles(String styles)Parameters
stylesString- style format
See also
getInlineUnselectedStyles
public String getInlineUnselectedStyles()Returns
setInlineUnselectedStyles
public void setInlineUnselectedStyles(String styles)Parameters
stylesString- style format
See also
getInlineDisabledStyles
public String getInlineDisabledStyles()Returns
setInlineDisabledStyles
public void setInlineDisabledStyles(String styles)Parameters
stylesString- style format
See also
getInlinePressedStyles
public String getInlinePressedStyles()Returns
setInlinePressedStyles
public void setInlinePressedStyles(String styles)Parameters
stylesString- style format
See also
remove
public void remove()getParent
public Container getParent()Returns
getOwner
public Component getOwner()#setOwner(com.codename1.ui.Component).Returns
setOwner
public void setOwner(Component owner)Sets the owner of this component to the specified component. This can be useful for denoting a hierarchical relationship that is outside the actual parent-child component hierarchy. E.g. If there is a popup dialog that allows the user to select input for a text field, then you could set the text field as the owner of the popup dialog to denote a virtual parent-child relationship.
This is used by InteractionDialog#setDisposeWhenPointerOutOfBounds(boolean) to figure out whether a
pointer event actually occurred outside the bounds of the dialog. The int) method
is used instead of int) so that it can cover the case where the pointer event occurred
on a component that is logically a child of the dialog, but not physically.
popup dialog is opened, then
Parameters
ownerComponent- The component to set as the owner of this component.
isOwnedBy
public boolean isOwnedBy(Component cmp)Checks to see if this component is owned by the given other component. A component A is deemed to be owned by another component B if any of the following conditions are true:
B is the owner of A
B contains A’s owner.
A’s owner is owned by B
Parameters
cmpComponent- the owner
Returns
containsOrOwns
public boolean containsOrOwns(int x, int y)Parameters
xint- X-coordinate in absolute coordinates.
yint- Y-coordinate in absolute coordinates.
Returns
addFocusListener
public void addFocusListener(FocusListener l)Parameters
lFocusListener- listener interface implementing the observable pattern
removeFocusListener
public void removeFocusListener(FocusListener l)Parameters
lFocusListener- listener interface implementing the observable pattern
addScrollListener
public void addScrollListener(ScrollListener l)Parameters
lScrollListener- listener interface implementing the observable pattern
removeScrollListener
public void removeScrollListener(ScrollListener l)Parameters
lScrollListener- listener interface implementing the observable pattern
fireClicked
protected void fireClicked()isSelectableInteraction
protected boolean isSelectableInteraction()Returns
getSelectCommandText
public String getSelectCommandText()Returns
setSelectCommandText
public void setSelectCommandText(String selectText)Parameters
selectTextString- text for the interaction with the softkey
getLabelForComponent
public Label getLabelForComponent()Returns
setLabelForComponent
public void setLabelForComponent(Label componentLabel)Parameters
componentLabelLabel- a label associated with this component
focusGained
protected void focusGained()focusLost
protected void focusLost()paintBackgrounds
public void paintBackgrounds(Graphics g)Parameters
gGraphics- the graphics object
paintShadows
public void paintShadows(Graphics g, int relativeX, int relativeY)Paints the drop-shadow projections for this component based on its elevation value.
This is called by the ancestor “surface” container of the component, after it paints its background, but
before painting its children. If the Style#getElevation() of the component is 0, then no shadow
will be painted. Similarly, if the component has no ancestor container which is a surface (i.e. Container#isSurface() is true,
the shadow will not be painted.
NOTE: It is also possible that the shadow will not be visible if other opaque components are painted in front of the ancestor surface container. This is one of the limitations of this approach for simulating elevation.
Note: Not all platforms support drawing shadows. Use CodenameOneImplementation#isDrawShadowSupported() to check
for support at runtime.
Parameters
gGraphics- The graphics context onto which the shadow should be painted.
relativeXint- The relative X coordinate onto which the shadow should be drawn.
relativeYint- The relative Y coordinate onto which the shadow should be drawn.
See also
Container#paintElevatedPane(Graphics)Container#isSurface()Style#getElevation()
getAbsoluteX
public int getAbsoluteX()Returns
See also
getAbsoluteY
public int getAbsoluteY()Returns
See also
isInClippingRegion
protected boolean isInClippingRegion(Graphics g)paintIntersectingComponentsAbove
public void paintIntersectingComponentsAbove(Graphics g)Parameters
gGraphics- Graphics context
paintScrollbars
protected void paintScrollbars(Graphics g)Parameters
gGraphics- the component graphics
paintScrollbarX
protected void paintScrollbarX(Graphics g)Parameters
gGraphics- the component graphics
getScrollOpacity
public int getScrollOpacity()Returns
getSelectedRect
public Rectangle getSelectedRect()Returns
paintScrollbarY
protected void paintScrollbarY(Graphics g)Parameters
gGraphics- the component graphics
paintComponent
public final void paintComponent(Graphics g)Paints this component as a root by going to all the parent components and setting the absolute translation based on coordinates and scroll status. Restores translation when the painting is finished.
One of the uses of this method is to create a “screenshot” as is demonstrated in the code below that creates an image for sharing on social media
Form hi = new Form("ShareButton");
ShareButton sb = new ShareButton();
sb.setText("Share Screenshot");
hi.add(sb);
Image screenshot = Image.createImage(hi.getWidth(), hi.getHeight());
hi.revalidate();
hi.setVisible(true);
hi.paintComponent(screenshot.getGraphics(), true);
String imageFile = FileSystemStorage.getInstance().getAppHomePath() + "screenshot.png";
try(OutputStream os = FileSystemStorage.getInstance().openOutputStream(imageFile)) {
ImageIO.getImageIO().save(screenshot, os, ImageIO.FORMAT_PNG, 1);
} catch(IOException err) {
Log.e(err);
}
sb.setImageToShare(imageFile, "image/png");
Parameters
gGraphics- the graphics to paint this Component on
paintComponent
public final void paintComponent(Graphics g, boolean background)Paints this component as a root by going to all the parent components and setting the absolute translation based on coordinates and scroll status. Restores translation when the painting is finished.
One of the uses of this method is to create a “screenshot” as is demonstrated in the code below that creates an image for sharing on social media
Form hi = new Form("ShareButton");
ShareButton sb = new ShareButton();
sb.setText("Share Screenshot");
hi.add(sb);
Image screenshot = Image.createImage(hi.getWidth(), hi.getHeight());
hi.revalidate();
hi.setVisible(true);
hi.paintComponent(screenshot.getGraphics(), true);
String imageFile = FileSystemStorage.getInstance().getAppHomePath() + "screenshot.png";
try(OutputStream os = FileSystemStorage.getInstance().openOutputStream(imageFile)) {
ImageIO.getImageIO().save(screenshot, os, ImageIO.FORMAT_PNG, 1);
} catch(IOException err) {
Log.e(err);
}
sb.setImageToShare(imageFile, "image/png");
Parameters
gGraphics- the graphics to paint this Component on
backgroundboolean- if true paints all parents background
getBorder
protected Border getBorder()Returns
getScrollable
public Component getScrollable()Returns
paintBackground
protected void paintBackground(Graphics g)Parameters
gGraphics- the component graphics
paint
public void paint(Graphics g)Parameters
gGraphics- the component graphics
isScrollable
protected boolean isScrollable()Returns
isScrollableX
public boolean isScrollableX()Returns
isScrollableY
public boolean isScrollableY()Returns
getScrollX
public int getScrollX()Returns
setScrollX
protected void setScrollX(int scrollX)Parameters
scrollXint- the X position of the scrolling
getScrollY
public int getScrollY()Returns
setScrollY
protected void setScrollY(int scrollY)Parameters
scrollYint- the Y position of the scrolling
onScrollX
protected void onScrollX(int scrollX)Parameters
scrollXint- the X position of the scrolling
onScrollY
protected void onScrollY(int scrollY)Parameters
scrollYint- the Y position of the scrolling
getDraggedx
public int getDraggedx()Returns
getDraggedy
public int getDraggedy()Returns
getBottomGap
public int getBottomGap()Returns
getSideGap
public int getSideGap()Returns
contains
public boolean contains(int x, int y)Returns true if the given absolute coordinate is contained in the Component
NOTE: This will return true upon a “hit” even if the component is not
visible, or if that part of the component is currently clipped by a parent
component. To check if a point is contained in the visible component bounds
use int)
Parameters
xint- the given absolute x coordinate
yint- the given absolute y coordinate
Returns
See also
visibleBoundsContains
public boolean visibleBoundsContains(int x, int y)int) in that it will
return false if the component or any of its ancestors are not visible,
or if (x, y) are contained inside the bounds of the component, but are clipped.Parameters
xint- the given absolute x coordinate
yint- the given absolute y coordinate
Returns
See also
calcPreferredSize
protected Dimension calcPreferredSize()Returns
hasFixedPreferredSize
public boolean hasFixedPreferredSize()#setPreferredH(int) and #setPreferredW(int), or via a preferred
size style string.Returns
getBounds
protected Rectangle getBounds()Returns the component bounds which is sometimes more convenient than invoking getX/Y/Width/Height. Bounds are relative to parent container.
Changing values within the bounds can lead to unpredicted behavior.
Returns
getBounds
public Rectangle getBounds(Rectangle rect)Parameters
rectRectangle- An “out” parameter to store the component bounds in. Cannot be null.
Returns
See also
getVisibleBounds
protected Rectangle getVisibleBounds()Returns
getVisibleBounds
public Rectangle getVisibleBounds(Rectangle rect)Parameters
rectRectangle- An “out” parameter to store the bounds in. Cannot be null.
Returns
See also
isFocusable
public boolean isFocusable()Returns
setFocusable
public final void setFocusable(boolean focusable)Parameters
focusableboolean- indicate whether this component can get focused
onSetFocusable
protected void onSetFocusable(boolean focusable)Parameters
focusableboolean- true if the component was made focusable
resetFocusable
protected void resetFocusable()getTabIndex
public int getTabIndex()#getPreferredTabIndex() to get the preferred tab index.Form#getTabIterator(com.codename1.ui.Component) on the
form or Container#updateTabIndices(int) in the parent component.Returns
setTabIndex
public void setTabIndex(int index)#setPreferredTabIndex(int) instead.#setPreferredTabIndex(int)Parameters
indexint- The tab index.
getPreferredTabIndex
public int getPreferredTabIndex()Gets the preferred tab index of this component. Tab indices are used to specify the traversal order when tabbing from component to component in a form.
Tab index meanings work similar to the HTML tabIndex attribute. A tab Index of -1 (the default value) results in the field not being traversable using the keyboard (or using the next/prev buttons in devices’ virtual keyboards). A tab index of 0 results in the component’s traversal order being dictated by the natural traversal order of the form.
Use Form#getTabIterator(com.codename1.ui.Component) to obtain the complete traversal order for
all components in the form.
Best practice is to only explicitly set preferred tabIndex values of 0 if you want the component to be traversable, or -1 if you don’t want the component to be traversable. Explicitly setting a positive preferred tab index may result in unexpected results.
How the Preferred Tab Index is Used
When the user tries to “tab” to the next field (or presses the “Next” button on the virtual keyboard), this
triggers a call to Form#getTabIterator(com.codename1.ui.Component), crawls the component hierarchy and
returns a java.util.ListIterator of all of the traversable fields in the form in the order they should
be traversed. This order is determined by the layout managers on the form. The core layout managers define
sensible traversal orders by default. If you have a custom layout manager, you can override its traversal
order by implementing the com.codename1.ui.layouts.Layout#overridesTabIndices(com.codename1.ui.Container) and
com.codename1.ui.layouts.Layout#getChildrenInTraversalOrder(com.codename1.ui.Container) methods.
Returns
setPreferredTabIndex
public void setPreferredTabIndex(int index)Parameters
indexint- The preferred tab index
isTraversable
public final boolean isTraversable()Checks if this component should be traversable using the keyboard using tab, next, previous keys.
Note: This method is marked final because it is just a convenience wrapper around #getPreferredTabIndex()
Returns
setTraversable
public final void setTraversable(boolean traversable)Sets whether this component is traversable using the keyboard using tab, next, previous keys. This is
just a wrapper around #setPreferredTabIndex(int) that sets the tab index to 0 if the component
should be traversable, and -1 if it shouldn’t be.
Note: This method is marked final because this is just a convenience wrapper around #setPreferredTabIndex(int)
Parameters
traversableboolean- True to make the component traversable.
setShouldCalcPreferredSize
public void setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)Parameters
shouldCalcPreferredSizeboolean- indicate whether this component need to recalculate his preferred size
handlesInput
public boolean handlesInput()Returns
setHandlesInput
public void setHandlesInput(boolean handlesInput)Parameters
handlesInputboolean- indicates whether key events can be grabbed for focus traversal
consumesRawTextInput
protected boolean consumesRawTextInput()Whether this component turns key codes into printable characters, as a text editor does.
Key codes and character codes share one value space, so a port is free to map a soft key
onto a value that is also a printable character: the desktop port maps the left soft key to
VK_F1, which is 112, the code of a lowercase p. A form serves a component that answers
true here before the menu bar, or that character could never be typed into it. This is
deliberately narrower than #handlesInput(), which components such as lists and editable
sliders also set for focus traversal while still expecting their soft keys to work.
Returns
hasFocus
public boolean hasFocus()Returns
See also
setFocus
public void setFocus(boolean focused)Parameters
focusedboolean- sets the state that determines what colors from the Style should be used when painting a focused component
See also
getComponentForm
public 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.
Returns
See also
repaint
public void repaint()See also
repaint
public void repaint(int x, int y, int w, int h)Parameters
xint- boundary of the region to repaint in absolute screen coordinates not component coordinates
yint- boundary of the region to repaint in absolute screen coordinates not component coordinates
wint- boundary of the region to repaint
hint- boundary of the region to repaint
longKeyPress
protected void longKeyPress(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
keyPressed
public void keyPressed(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
keyReleased
public void keyReleased(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
keyRepeated
public void keyRepeated(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
registerForAnimation
protected void registerForAnimation()deregisterFromAnimation
protected void deregisterFromAnimation()getAnimationManager
public AnimationManager getAnimationManager()getScrollAnimationSpeed
public int getScrollAnimationSpeed()Returns
setScrollAnimationSpeed
public void setScrollAnimationSpeed(int animationSpeed)Parameters
animationSpeedint- scroll animation speed in milliseconds
isBlockLead
public boolean isBlockLead()Returns
setBlockLead
public void setBlockLead(boolean blockLead)Parameters
blockLeadboolean- the blockLead to set
isIgnorePointerEvents
public boolean isIgnorePointerEvents()Returns
setIgnorePointerEvents
public void setIgnorePointerEvents(boolean ignorePointerEvents)Parameters
ignorePointerEventsboolean- the ignorePointerEvents to set
isRippleEffect
public boolean isRippleEffect()Returns
setRippleEffect
public void setRippleEffect(boolean rippleEffect)Parameters
rippleEffectboolean- the rippleEffect to set
getInlineStylesTheme
public Resources getInlineStylesTheme()Returns
setInlineStylesTheme
public void setInlineStylesTheme(Resources inlineStylesTheme)Parameters
inlineStylesThemeResources- the theme that inline styles use to reference images.
shouldRenderComponentSelection
protected boolean shouldRenderComponentSelection()Returns
isHideInLandscape
public boolean isHideInLandscape()Returns
setHideInLandscape
public void setHideInLandscape(boolean hideInLandscape)Parameters
hideInLandscapeboolean- the hideInLandscape to set
createStyleAnimation
public ComponentAnimation createStyleAnimation(String destUIID, int duration)Creates an animation that will transform the current component to the styling of the destination UIID when completed. Notice that fonts will only animate within the truetype and native familiy and we recommend that you don’t shift weight/typeface/style as this might diminish the effect.
**Important: ** Only unselected styles are animated but once the animation completes all styles are applied.
Parameters
destUIIDString- the UIID to which this component will gradually shift
durationint- the duration of the animation or the number of steps
Returns
isSmoothScrolling
public boolean isSmoothScrolling()Returns
setSmoothScrolling
public void setSmoothScrolling(boolean smoothScrolling)Parameters
smoothScrollingboolean- indicates if a component uses smooth scrolling
pointerHover
public void pointerHover(int[] x, int[] y)Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
stopScrollMomentum
public void stopScrollMomentum()Stops any momentum or tensile scroll animation currently running on this component, leaving the scroll position exactly where it is.
This is for a component that wants to take over after the finger lifts and drive the
scroll itself - a paging/snapping container being the usual case. Codename One starts
its own decay from #pointerReleased(int, int), so without this the component’s own
animation and the built-in momentum both run, and the result is the scroll coasting
to a halt and then visibly moving a second time.
Unlike #clearDrag() this affects only this component: an ancestor that is
legitimately scrolling on the other axis keeps its momentum.
See also
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
pinch
protected boolean pinch(float scale)Parameters
scalefloat- the scaling of the pinch operation a number larger than 1 means scaling up and smaller than 1 means scaling down. It is recommended that code would threshold the number (so a change between 1.0 and 1.02 shouldn’t necessarily trigger zoom). Notice that this number is relevant to current zoom levels and unaware of them so you should also enforce limits of maximum/minimum zoom levels.
Returns
pinchReleased
protected void pinchReleased(int x, int y)Parameters
xint- The x-coordinate of the remaining finger in the drag. (Absolute)
yint- The y-coordinate of the remaining finger in the drag. (Absolute)
pinch
protected boolean pinch(int[] x, int[] y)Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
Returns
rotation
protected boolean rotation(float radians)Parameters
radiansfloat- the incremental rotation in radians since the previous callback; positive is clockwise
Returns
isPinchBlocksDragAndDrop
public boolean isPinchBlocksDragAndDrop()setPinchBlocksDragAndDrop
public void setPinchBlocksDragAndDrop(boolean block)Parameters
blockboolean- if true will prevent drag and drop to trigger if two fingers are placed to pinch before the drag is initiated
pointerDragged
public void pointerDragged(int[] x, int[] y)Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
getDragImage
protected Image getDragImage()Returns
getDragTransparency
public byte getDragTransparency()#getDragImage() method.Returns
setDragTransparency
public void setDragTransparency(byte dragTransparency)#getDragImage() method.Parameters
dragTransparencybyte- a number between 0 and 255 where 255 indicates an opaque image.
toImage
public Image toImage()Returns
dragInitiated
protected void dragInitiated()drawDraggedImage
protected void drawDraggedImage(Graphics g, Image img, int x, int y)Parameters
gGraphics- the graphics context
imgImage- the image
xint- x position
yint- y position
draggingOver
protected boolean draggingOver(Component dragged, int x, int y)Parameters
draggedComponent- the component being dragged
xint- the x location over the component
yint- the y location over the component
Returns
dragEnter
protected void dragEnter(Component dragged)Parameters
draggedComponent- the component being dragged
dragExit
protected void dragExit(Component dragged)Parameters
draggedComponent- the component being dragged
drop
public void drop(Component dragged, int x, int y)Parameters
draggedComponent- the component being dropped
xint- the x coordinate of the drop
yint- the y coordinate of the drop
addPullToRefresh
public void addPullToRefresh(Runnable task)This method adds a refresh task to the Component, the task will be executed if the user has pulled the scroll beyond a certain height.
Form hi = new Form("Pull To Refresh", BoxLayout.y());
hi.getContentPane().addPullToRefresh(() -> {
hi.add("Pulled at " + L10NManager.getInstance().formatDateTimeShort(new Date()));
});
hi.show();
Parameters
taskRunnable- the refresh task to execute.
setPullToRefresh
public void setPullToRefresh(Runnable task)#addPullToRefresh(Runnable) – both names point at the
same single-task slot, and a second call replaces the
previously-registered runnable.Parameters
taskRunnable- the refresh task to execute, or
nullto clear.
respondsToPointerEvents
public boolean respondsToPointerEvents()#isGrabsPointerEvents() flag true.Returns
pointerDragged
public void pointerDragged(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
isStickyDrag
protected boolean isStickyDrag()Returns
pointerPressed
public void pointerPressed(int[] x, int[] y)Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
isDragAndDropOperation
protected boolean isDragAndDropOperation(int x, int y)Parameters
xint- the x coordinate relative to the component
yint- the y coordinate relative to the component
Returns
pointerPressed
public void pointerPressed(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
pointerReleased
public void pointerReleased(int[] x, int[] y)Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
longPointerPress
public void longPointerPress(int x, int y)pointerReleased
public void pointerReleased(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
setVerticalScrollBounds
public void setVerticalScrollBounds(int thumbX, int thumbY, int thumbW, int thumbH, int trackX, int trackY, int trackW, int trackH)Parameters
thumbXint- component-local x of the thumb
thumbYint- component-local y of the thumb
thumbWint- thumb width
thumbHint- thumb height
trackXint- component-local x of the track
trackYint- component-local y of the track
trackWint- track width
trackHint- track height
setHorizontalScrollBounds
public void setHorizontalScrollBounds(int thumbX, int thumbY, int thumbW, int thumbH, int trackX, int trackY, int trackW, int trackH)#setVerticalScrollBounds(int, int, int, int, int, int, int, int).Parameters
thumbXint- component-local x of the thumb
thumbYint- component-local y of the thumb
thumbWint- thumb width
thumbHint- thumb height
trackXint- component-local x of the track
trackYint- component-local y of the track
trackWint- track width
trackHint- track height
isVScrollThumbGrabbed
public boolean isVScrollThumbGrabbed()Returns
isHScrollThumbGrabbed
public boolean isHScrollThumbGrabbed()Returns
isVScrollThumbHover
public boolean isVScrollThumbHover()Returns
isHScrollThumbHover
public boolean isHScrollThumbHover()Returns
isTensileDragEnabled
public boolean isTensileDragEnabled()Returns
setTensileDragEnabled
public void setTensileDragEnabled(boolean tensileDragEnabled)Parameters
tensileDragEnabledboolean- true to enable tensile drag
getTextSelectionSupport
public TextSelection.TextSelectionSupport getTextSelectionSupport()Returns
addDropListener
public void addDropListener(ActionListener l)Parameters
lActionListener- the callback
removeDropListener
public void removeDropListener(ActionListener l)Parameters
lActionListener- the callback
addDragOverListener
public void addDragOverListener(ActionListener l)Parameters
lActionListener- the listener
removeDragOverListener
public void removeDragOverListener(ActionListener l)Parameters
lActionListener- the callback
isNativeDragSource
public boolean isNativeDragSource()setNativeDragSource
public void setNativeDragSource(boolean nativeDragSource)Makes a drag that starts on this component an operating system drag, which can be dropped outside the application.
Supply what is being dragged either by calling
#setNativeDragOperation(com.codename1.ui.NativeDragOperation), or by overriding
#createNativeDragOperation(int, int) when the payload depends on where the press
landed – which item of a list was grabbed, for instance.
This is independent of #setDraggable(boolean). Where the platform has no native drag
and drop this flag simply does nothing, so a component that should be draggable either
way sets both and the native session, when there is one, takes precedence.
Parameters
nativeDragSourceboolean- true to hand drags on this component to the operating system
getNativeDragOperation
public NativeDragOperation getNativeDragOperation()#createNativeDragOperation(int, int).setNativeDragOperation
public void setNativeDragOperation(NativeDragOperation nativeDragOperation)Sets what dragging this component puts on the operating system’s drag, and makes the component a native drag source. Passing null clears both.
The operation is reusable: the same instance is offered for every drag of this
component, so it must not hold state from a previous session. Anything expensive in the
payload belongs behind
ClipboardContent#setDataProvider(java.lang.String, com.codename1.ui.ClipboardDataProvider).
Parameters
nativeDragOperationNativeDragOperation- what to drag, or null to stop being a drag source
createNativeDragOperation
protected NativeDragOperation createNativeDragOperation(int x, int y)Produces the operation for a drag starting at the given position, invoked on the event
dispatch thread as the press is dispatched. Override when the payload depends on where
the user grabbed the component; the default returns whatever
#setNativeDragOperation(com.codename1.ui.NativeDragOperation) was given.
Returning null, or an operation allowing no actions, leaves the gesture alone – which is how a component refuses to be dragged from a particular spot.
Parameters
xint- the absolute x position of the press
yint- the absolute y position of the press
Returns
isNativeDropTarget
public boolean isNativeDropTarget()setNativeDropTarget
public void setNativeDropTarget(boolean nativeDropTarget)Lets this component receive drops from the operating system: from another application, from a file manager, from the desktop, or from elsewhere in this application.
The deepest component under the pointer that is a native drop target and accepts the content wins, so a target nested inside another target takes precedence – and a target that refuses a particular payload lets an ancestor have it.
This is independent of #setDropTarget(boolean), which governs the lightweight drag and
drop inside the form.
Parameters
nativeDropTargetboolean- true to accept operating system drops
getAcceptedDropMimeTypes
public String[] getAcceptedDropMimeTypes()setAcceptedDropMimeTypes
public void setAcceptedDropMimeTypes(String... acceptedDropMimeTypes)Restricts the drops this component accepts to drags offering at least one of these MIME types, so a drag carrying anything else passes through to whatever is behind it.
This filter is consulted on the platform’s drag thread rather than the event dispatch
thread, which is what lets the answer be exact from the very first drag event; see
NativeDragAndDrop#dragOver(int, int, int, com.codename1.ui.ClipboardContent, int).
Parameters
acceptedDropMimeTypesString...- the MIME types, for instance
ClipboardContent#MIME_FILE, or null to accept anything
getAcceptedDropActions
public int getAcceptedDropActions()setAcceptedDropActions
public void setAcceptedDropActions(int acceptedDropActions)Restricts what this component will do with a drop – a target that can only copy should not be offered a move, because the source deletes its data when a move completes.
Settled before a drag begins. Narrowing this while one is already hovering is honoured from whichever drag event next reaches the framework – the hover answers the platform on the platform’s own thread – so a target changing its mind mid-drag should reject from its drag over callback, which is ordered against the drag rather than against the component.
Parameters
acceptedDropActionsint- any combination of
NativeDragOperation#ACTION_COPY,NativeDragOperation#ACTION_MOVEandNativeDragOperation#ACTION_LINK
canAcceptNativeDrop
protected boolean canAcceptNativeDrop(ClipboardContent content)Decides whether this component wants a drag carrying these representations at all.
Threading
Invoked on the platform’s drag thread, not the event dispatch thread, because the
operating system needs the answer while the pointer is moving. Read the content and
this component’s own configuration; do not touch the user interface, start animations
or block. Everything that needs the event dispatch thread belongs in
#nativeDragEnter(com.codename1.ui.NativeDropEvent) and its siblings.
The default accepts anything unless
#setAcceptedDropMimeTypes(java.lang.String...) narrowed it.
What the content holds here
The MIME types the drag is offering, and not their values: decide on the types. A
drag in progress has not handed its data over yet, and on most platforms it cannot
be made to – so ClipboardContent#getData(java.lang.String) answers null here even
for a representation the drop will produce. Reading it is not merely unhelpful
either: a representation a source can vend only once would be spent before the drop
could read it. #nativeDrop(com.codename1.ui.NativeDropEvent) is where the values
exist, and by then they are all there.
Parameters
contentClipboardContent- the representations the drag is offering, by name
Returns
nativeDragEnter
protected void nativeDragEnter(NativeDropEvent ev)NativeDropEvent#accept(int) or
NativeDropEvent#reject() to change what the cursor tells the user.Parameters
evNativeDropEvent- the drag
nativeDragOver
protected void nativeDragOver(NativeDropEvent ev)Parameters
evNativeDropEvent- the drag
nativeDragExit
protected void nativeDragExit(NativeDropEvent ev)#nativeDragEnter(com.codename1.ui.NativeDropEvent)
highlighted. The event carries no content.Parameters
evNativeDropEvent- the drag
nativeDrop
protected void nativeDrop(NativeDropEvent ev)Callback invoked on the event dispatch thread when a native drag is dropped on this
component. NativeDropEvent#getContent() names everything the drop carries, and its
values are readable from here on.
Reading it later
Read what the drop is for while handling it. A representation may be backed by the platform’s own transfer rather than by bytes this application owns – Android hands over a content URI readable under a permission granted to the activity, and iOS copies a dropped file into temporary storage – so a value first asked for long afterwards, and particularly after the activity that received the drop has gone, may no longer be there.
A value once read is kept, so reading here and holding the result is always safe. Deliberately not read for you: a drop of a large document on a component that only wants its path would otherwise pay for every byte of it, on the very thread the platform is waiting on.
Parameters
evNativeDropEvent- the drop
addNativeDropListener
public void addNativeDropListener(ActionListener l)NativeDropEvent.Parameters
lActionListener- the listener
removeNativeDropListener
public void removeNativeDropListener(ActionListener l)#addNativeDropListener(com.codename1.ui.events.ActionListener).Parameters
lActionListener- the listener
addNativeDragOverListener
public void addNativeDragOverListener(ActionListener l)NativeDropEvent; its
com.codename1.ui.events.ActionEvent#getEventType() says which of the three it is.Parameters
lActionListener- the listener
removeNativeDragOverListener
public void removeNativeDragOverListener(ActionListener l)#addNativeDragOverListener(com.codename1.ui.events.ActionListener).Parameters
lActionListener- the listener
dragFinished
protected void dragFinished(int x, int y)Parameters
xint- the x location
yint- the y location
addDragFinishedListener
public void addDragFinishedListener(ActionListener l)Parameters
lActionListener- callback to receive drag finished events events
addStateChangeListener
public void addStateChangeListener(ActionListener<ComponentStateChangeEvent> l)Parameters
lActionListener<ComponentStateChangeEvent>- Listener to be subscribed.
removeStateChangeListener
public void removeStateChangeListener(ActionListener<ComponentStateChangeEvent> l)Parameters
lActionListener<ComponentStateChangeEvent>- Listener to be unsubscribed.
addPointerPressedListener
public void addPointerPressedListener(ActionListener l)Parameters
lActionListener- callback to receive pointer events
addLongPressListener
public void addLongPressListener(ActionListener l)Parameters
lActionListener- callback to receive pointer events
addContextMenuListener
public void addContextMenuListener(ActionListener l)com.codename1.ui.events.ActionEvent carries the pointer location and, via
com.codename1.ui.events.ActionEvent#getPointerEvent(), the button and pointer type detail.Parameters
lActionListener- callback to receive context menu requests
removeContextMenuListener
public void removeContextMenuListener(ActionListener l)Parameters
lActionListener- callback to remove
addMouseWheelListener
public void addMouseWheelListener(ActionListener l)com.codename1.ui.events.WheelEvent exposing the scroll deltas and modifiers. Consuming the
event with com.codename1.ui.events.ActionEvent#consume() prevents the default scrolling
behavior, which is useful for gestures such as control plus wheel to zoom.Parameters
lActionListener- callback to receive wheel events
removeMouseWheelListener
public void removeMouseWheelListener(ActionListener l)Parameters
lActionListener- callback to remove
addStylusListener
public void addStylusListener(ActionListener l)com.codename1.ui.events.ActionEvent#getPointerEvent() including pressure and tilt.Parameters
lActionListener- callback to receive stylus events
removeStylusListener
public void removeStylusListener(ActionListener l)Parameters
lActionListener- callback to remove
mouseWheel
protected boolean mouseWheel(WheelEvent ev)Handles a scroll wheel or trackpad scroll over this component, before its listeners and before anything above it in the hierarchy.
A component that moves its own content – an editor that scrolls itself, a viewer that pans – implements this. Everything else leaves it alone and the wheel scrolls the nearest scrollable ancestor, which is what a wheel means.
This exists because a wheel used to arrive as a synthetic press, drag and release played into the component tree: a component that wanted the wheel got it by handling pointer events, and so did every component that did not want it. The events are gone and this is what replaces them, for the few components that have something of their own to move.
Parameters
evWheelEvent- the wheel event, carrying the scroll deltas in display pixels
Returns
paintRippleOverlay
public void paintRippleOverlay(Graphics g, int x, int y, int position)Parameters
gGraphics- the graphics object for the component clipped to the background
xint- the x position of the touch
yint- the y position of the touch
positionint- a value between 0 and 1000 with 0 indicating the beginning of the ripple effect and 1000 indicating the completion of it
removePointerPressedListener
public void removePointerPressedListener(ActionListener l)Parameters
lActionListener- callback to remove
removeLongPressListener
public void removeLongPressListener(ActionListener l)Parameters
lActionListener- callback to remove
removeDragFinishedListener
public void removeDragFinishedListener(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
addPointerDraggedListener
public void addPointerDraggedListener(ActionListener l)Parameters
lActionListener- callback to receive pointer events
removePointerDraggedListener
public void removePointerDraggedListener(ActionListener l)Parameters
lActionListener- callback to remove
getDragSpeed
protected float getDragSpeed(boolean vertical)Parameters
verticalboolean- indicates what axis speed is required
Returns
getStyle
public Style getStyle()Returns
getPressedStyle
public Style getPressedStyle()Returns
setPressedStyle
public void setPressedStyle(Style style)Parameters
styleStyle- the component Style object
initUnselectedStyle
protected void initUnselectedStyle(Style unselectedStyle)Parameters
unselectedStyleStyle- The unselected style.
initPressedStyle
protected void initPressedStyle(Style pressedStyle)initDisabledStyle
protected void initDisabledStyle(Style disabledStyle)initSelectedStyle
protected void initSelectedStyle(Style selectedStyle)getUnselectedStyle
public final Style getUnselectedStyle()Returns
setUnselectedStyle
public void setUnselectedStyle(Style style)Parameters
styleStyle- the component Style object
getSelectedStyle
public Style getSelectedStyle()Returns
setSelectedStyle
public void setSelectedStyle(Style style)Parameters
styleStyle- the component Style object
getDisabledStyle
public Style getDisabledStyle()Returns
setDisabledStyle
public void setDisabledStyle(Style style)Parameters
styleStyle- the component Style object
installDefaultPainter
protected void installDefaultPainter(Style s)Parameters
sStyle- the custom style
requestFocus
public void requestFocus()toString
public String toString()Returns
paramString
protected String paramString()null.Returns
refreshTheme
public void refreshTheme()refreshTheme
public void refreshTheme(boolean merge)Parameters
mergeboolean- indicates if the current styles should be merged with the new styles
refreshTheme
protected void refreshTheme(String id, boolean merge)Parameters
idString- The Style Id to update the Component with
mergeboolean- indicates if the current styles should be merged with the new styles
isDragActivated
protected boolean isDragActivated()Returns
getGridPosY
protected int getGridPosY()Returns
getGridPosX
protected int getGridPosX()Returns
animate
public boolean animate()com.codename1.ui.Display class.Returns
scrollRectToVisible
protected void scrollRectToVisible(Rectangle rect, Component coordinateSpace)Parameters
rectRectangle- the rectangle that need to be visible
coordinateSpaceComponent- the component according to whose coordinates rect is defined. Rect’s x/y are relative to that component (they are not absolute).
scrollRectToVisible
public void scrollRectToVisible(int x, int y, int width, int height, Component coordinateSpace)Parameters
xint- Not documented.
yint- Not documented.
widthint- Not documented.
heightint- Not documented.
coordinateSpaceComponent- the component according to whose coordinates rect is defined. Rect’s x/y are relative to that component (they are not absolute).
paintBorder
protected void paintBorder(Graphics g)Parameters
gGraphics- graphics context on which the border is painted
paintBorderBackground
protected void paintBorderBackground(Graphics g)Parameters
gGraphics- graphics context on which the border is painted
isCellRenderer
public boolean isCellRenderer()Returns
setCellRenderer
public void setCellRenderer(boolean cellRenderer)Parameters
cellRendererboolean- indicate whether this component is currently being used as a cell renderer
isScrollVisible
public boolean isScrollVisible()Returns
setScrollVisible
public void setScrollVisible(boolean isScrollVisible)Parameters
isScrollVisibleboolean- Indicate whether this component scroll is visible
setIsScrollVisible
public void setIsScrollVisible(boolean isScrollVisible)Parameters
isScrollVisibleboolean- Indicate whether this component scroll is visible
startEditingAsync
public void startEditingAsync()#isEditable(), then this will start the editing
process. For TextFields, this results in showing the keyboard and allowing
the user to edit the input. For the Picker, this will display the popup.stopEditing
public void stopEditing(Runnable onFinish)Parameters
onFinishRunnable- Callback called when the editing is complete.
isEditing
public boolean isEditing()Returns
isEditable
public boolean isEditable()laidOut
protected void laidOut()deinitialize
protected void deinitialize()initComponent
protected void initComponent()isInitialized
protected boolean isInitialized()Returns
setInitialized
protected void setInitialized(boolean initialized)Parameters
initializedboolean- Indicates if the component is in the initialized state
styleChanged
public void styleChanged(String propertyName, Style source)Invoked to indicate a change in a propertyName of a Style
NOTE By default this will trigger a call to Container#revalidate() on the parent
container, which is expensive. You can disable this behavior by calling CN.setProperty("Component.revalidateOnStyleChange", "false").
The intention is to change this behavior so that the default is to “not” revalidate on style change, so we encourage you to
set this to “false” to ensure for future compatibility.
Parameters
propertyNameString- the property name that was changed
sourceStyle- The changed Style object
getNextFocusDown
public Component getNextFocusDown()Returns
setNextFocusDown
public void setNextFocusDown(Component nextFocusDown)Parameters
nextFocusDownComponent- the next focus component
getNextFocusUp
public Component getNextFocusUp()Returns
setNextFocusUp
public void setNextFocusUp(Component nextFocusUp)Parameters
nextFocusUpComponent- next focus component
getNextFocusLeft
public Component getNextFocusLeft()Returns
setNextFocusLeft
public void setNextFocusLeft(Component nextFocusLeft)Parameters
nextFocusLeftComponent- the next focus component
getNextFocusRight
public Component getNextFocusRight()Returns
setNextFocusRight
public void setNextFocusRight(Component nextFocusRight)Parameters
nextFocusRightComponent- the next focus component
isEnabled
public boolean isEnabled()Returns
setEnabled
public void setEnabled(boolean enabled)Parameters
enabledboolean- true to enable false to disable
getName
public String getName()Returns
setName
public void setName(String name)Parameters
nameString- a name for the component
initCustomStyle
protected void initCustomStyle(Style s)Parameters
sStyle- style to initialize
deinitializeCustomStyle
protected void deinitializeCustomStyle(Style s)Parameters
sStyle- style no longer used
isRTL
public final boolean isRTL()Returns
setRTL
public void setRTL(boolean rtl)Parameters
rtlboolean- true if the component should work in a right to left mode
isTactileTouch
protected boolean isTactileTouch(int x, int y)Parameters
xint- the x position
yint- the y position
Returns
isTactileTouch
public boolean isTactileTouch()Returns
setTactileTouch
public void setTactileTouch(boolean tactileTouch)Parameters
tactileTouchboolean- true to trigger vibration when the component is pressed
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
paintLockRelease
public void paintLockRelease()paintLock
public Image paintLock(boolean hardLock)This method locks the component so it will always paint the given image instead of running through its paint logic. This is useful when running transitions that might be quite expensive on the device. A lock should be released using paintLockRelease(), it is implicitly released when a component is deinitialized although a component doesn’t need to be initialized to be locked!
If the component is not opaque null is always returned!
Duplicate calls to this method won’t produce duplicate locks, in case of a soft lock the return value will always be null.
Parameters
hardLockboolean- indicates whether the lock uses a hard or a soft reference to the image
Returns
isSnapToGrid
public boolean isSnapToGrid()Returns
setSnapToGrid
public void setSnapToGrid(boolean snapToGrid)Parameters
snapToGridboolean- the snapToGrid to set
shouldBlockSideSwipe
protected boolean shouldBlockSideSwipe()shouldBlockSideSwipeLeft
protected boolean shouldBlockSideSwipeLeft()shouldBlockSideSwipeRight
protected boolean shouldBlockSideSwipeRight()blocksSideSwipe
public final boolean blocksSideSwipe()A component that might need side swipe such as the slider could block it from being used for some other purpose when on top of said component.
This method is merely a public accessor for #shouldBlockSideSwipe().
isFlatten
public boolean isFlatten()Returns
setFlatten
public void setFlatten(boolean flatten)Parameters
flattenboolean- the flatten value
getTensileLength
public int getTensileLength()Returns
setTensileLength
public void setTensileLength(int tensileLength)Parameters
tensileLengthint- length for tensile drag
isGrabsPointerEvents
public boolean isGrabsPointerEvents()Returns
setGrabsPointerEvents
public void setGrabsPointerEvents(boolean grabsPointerEvents)Parameters
grabsPointerEventsboolean- the grabsPointerEvents to set
getScrollOpacityChangeSpeed
public int getScrollOpacityChangeSpeed()Returns
setScrollOpacityChangeSpeed
public void setScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed)Parameters
scrollOpacityChangeSpeedint- the scrollOpacityChangeSpeed to set
growShrink
public void growShrink(int duration)Parameters
durationint- the duration in milliseconds for the grow/shrink animation
isAlwaysTensile
public boolean isAlwaysTensile()Returns
setAlwaysTensile
public void setAlwaysTensile(boolean alwaysTensile)Parameters
alwaysTensileboolean- the alwaysTensile to set
isDraggable
public boolean isDraggable()Returns
setDraggable
public void setDraggable(boolean draggable)Parameters
draggableboolean- the draggable to set
isDropTarget
public boolean isDropTarget()Returns
setDropTarget
public void setDropTarget(boolean dropTarget)Parameters
dropTargetboolean- the dropTarget to set
isChildOf
public boolean isChildOf(Container cnt)Parameters
cntContainer- a potential parent of this component
Returns
isHideInPortrait
public boolean isHideInPortrait()Returns
setHideInPortrait
public void setHideInPortrait(boolean hideInPortrait)Parameters
hideInPortraitboolean- set to true in order to hide when in portrait
cancelRepaints
protected void cancelRepaints()getBindablePropertyNames
public String[] getBindablePropertyNames()Returns
getBindablePropertyTypes
public Class[] getBindablePropertyTypes()Returns
bindProperty
public void bindProperty(String prop, BindTarget target)Parameters
propString- the property name
targetBindTarget- the target binder
unbindProperty
public void unbindProperty(String prop, BindTarget target)Parameters
propString- the property names
targetBindTarget- the target binder
getBoundPropertyValue
public Object getBoundPropertyValue(String prop)Parameters
propString- the property
Returns
setBoundPropertyValue
public void setBoundPropertyValue(String prop, Object value)Parameters
propString- the property whose value should be set
valueObject- the value
getCloudBoundProperty
public String getCloudBoundProperty()Returns
setCloudBoundProperty
public void setCloudBoundProperty(String cloudBoundProperty)Parameters
cloudBoundPropertyString- the cloudBoundProperty to set
getCloudDestinationProperty
public String getCloudDestinationProperty()Returns
setCloudDestinationProperty
public void setCloudDestinationProperty(String cloudDestinationProperty)Parameters
cloudDestinationPropertyString- the cloudDestinationProperty to set
getComponentState
public Object getComponentState()Returns
setComponentState
public void setComponentState(Object state)Parameters
stateObject- the non-null state
setHidden
public void setHidden(boolean b, boolean changeMargin)Parameters
bboolean- true to hide the component and false to show it
changeMarginboolean- indicates margin should be set to 0
isHidden
public boolean isHidden()#isHidden(boolean) with true
to check also if the parent is hidden.Returns
setHidden
public void setHidden(boolean b)Parameters
bboolean- true to hide the component and false to show it
isHidden
public boolean isHidden(boolean checkParent)Parameters
checkParentboolean- True to check if parent is hidden also.
Returns
announceForAccessibility
public void announceForAccessibility(String text)Parameters
textString- the message to announce
getAccessibilityText
public String getAccessibilityText()Returns
null if nonesetAccessibilityText
public void setAccessibilityText(String text)Parameters
textString- accessibility description
getSemantics
public AccessibilityNode getSemantics()Returns
getAccessibilityNode
public AccessibilityNode getAccessibilityNode()getSemantics() for APIs that use accessibility-node terminology.accessibilityChanged
public void accessibilityChanged()accessibilityChanged
public void accessibilityChanged(int changeType)getTooltip
public String getTooltip()Returns
setTooltip
public void setTooltip(String tooltip)Parameters
tooltipString- the tooltip to set