Class Component

java.lang.Object
com.codename1.ui.Component
All Implemented Interfaces:
Animation, Editable, StyleListener
Direct Known Subclasses:
ChartComponent, CommonProgressAnimations.ProgressAnimation, Container, ImageViewer, InfiniteProgress, Label, List, PeerComponent, Switch, TextArea

public class Component extends Object implements Animation, StyleListener, Editable

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.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Alignment to the baseline constraint
    static final int
    Box-orientation constant used to specify the bottom of a box.
    static final int
    Baseline resize behavior constant used to properly align components.
    static final int
    Baseline resize behavior constant used to properly align components.
    static final int
    Baseline resize behavior constant used to properly align components.
    static final int
    Baseline resize behavior constant used to properly align components.
    static final int
    Indicates a Component center alignment
    static final int
    The crosshair cursor type.
    static final int
    The default cursor
    static final int
    Used by getDragRegionStatus to indicate immediate dragability
    static final int
    Used by getDragRegionStatus to indicate immediate dragability
    static final int
    Used by getDragRegionStatus to indicate immediate dragability
    static final int
    Used by getDragRegionStatus to indicate likely dragability
    static final int
    Used by getDragRegionStatus to indicate likely dragability
    static final int
    Used by getDragRegionStatus to indicate likely dragability
    static final int
    Used by getDragRegionStatus to indicate no dragability
    static final int
    Used by getDragRegionStatus to indicate limited dragability
    static final int
    Used by getDragRegionStatus to indicate limited dragability
    static final int
    Used by getDragRegionStatus to indicate limited dragability
    static final int
    The east-resize cursor type.
    static final int
    The hand cursor type.
    static final int
    Box-orientation constant used to specify the left side of a box.
    static final int
    The move cursor type.
    static final int
    The north-resize cursor type.
    static final int
    The north-east-resize cursor type.
    static final int
    The north-west-resize cursor type.
    static final int
    Box-orientation constant used to specify the right side of a box.
    static final int
    The south-resize cursor type.
    static final int
    The south-east-resize cursor type.
    static final int
    The south-west-resize cursor type.
    static final int
    The text cursor type.
    static final int
    Box-orientation constant used to specify the top of a box.
    static final int
    The west-resize cursor type.
    static final int
    The wait cursor type.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new instance of Component
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a listener to the dragFinished event
    void
    Broadcasts an event when dragging over a component
    void
    Binds an action listener to drop events which are invoked when this component is dropped on a target
    void
    Registers interest in receiving callbacks for focus gained events, a focus event is invoked when the component accepts the focus.
    void
    Adds a listener to the pointer event
    void
    Adds a listener to the pointer event
    void
    Adds a listener to the pointer event
    void
    Adds a listener to the pointer event
    void
    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.
    void
    Registers interest in receiving callbacks for scroll gained events, a scroll event is invoked when the component is scrolled.
    void
    Adds a listener to be notified when the state of this component is changed to and from initialized.
    boolean
    Allows the animation to reduce "repaint" calls when it returns false.
    void
    Manually announces text to native accessibility services, associating the announcement with this component when possible.
    void
    Binds the given property name to the given bind target
    final boolean
    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 Dimension
    Calculates the preferred size based on component content.
    protected Dimension
    Method that can be overriden to represent the actual size of the component when it differs from the desireable size for the viewport
    protected void
    remove this component from the painting queue
    void
    Clears all client properties from this Component
    boolean
    contains(int x, int y)
    Returns true if the given absolute coordinate is contained in the Component
    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.
    createStyleAnimation(String destUIID, int duration)
    Creates an animation that will transform the current component to the styling of the destination UIID when completed.
    protected void
    Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.
    protected void
    Allows components to create a style of their own, this method cleans up state for the given style
    protected void
    This callback method indicates that a component drag has just entered this component
    protected void
    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.
    protected void
    dragFinished(int x, int y)
    Callback indicating that the drag has finished either via drop or by releasing the component
    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
    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
    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 dragging a component and dropping it has no effect
    protected void
    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 void
    Callback allowing a developer to track when the component gains focus
    protected void
    Callback allowing a developer to track wheh the component loses focus
    int
    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()
    int
    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()
    Returns the text that describes this component to assistive technologies.
    final Style
    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.
    Returns the animation manager of the parent form or null if this component isn't currently associated with a form
    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.
    int
    Returns a constant indicating how the baseline varies with the size of the component.
    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
    Returns the types of the properties that are bindable within this component
    protected Border
    Normally returns getStyle().getBorder() but some subclasses might use this to programmatically replace the border in runtime e.g.
    int
    Returns the gap to be left for the bottom scrollbar on the X axis.
    Allows the binding code to extract the value of the property
    protected Rectangle
    Returns the component bounds which is sometimes more convenient than invoking getX/Y/Width/Height.
    Returns the bounds of this component in the provided Rectangle.
    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.
    Indicates the property within this component that should be bound to the cloud object
    The destination property of the CloudObject
    Returns the Component Form or null if this Component is not added yet to a form
    Some components may optionally generate a state which can then be restored using setCompnentState().
    int
    Gets the custom cursor for this component.
    static byte
    Returns the default translucency used in the #getDragImage() method.
    final Rectangle
    gets the Component dirty region, this method is for internal use only and SHOULD NOT be invoked by user code.
    Returns the Component Style for the disabled state allowing us to manipulate the look of the component when its disabled
    int
    Gets the current dragged x values when the Component is being dragged
    int
    Gets the current dragged y values when the Component is being dragged
    protected Image
    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
    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.
    protected float
    getDragSpeed(boolean vertical)
    This method returns the dragging speed based on the latest dragged events
    byte
    Returns the translucency used in the #getDragImage() method.
    Gets the delegate that handles the editing of this component.
    protected int
    This method should be implemented correctly by subclasses to make snap to grid functionality work as expected.
    protected int
    This method should be implemented correctly by subclasses to make snap to grid functionality work as expected.
    int
    Returns the component height
    Gets inline styles that are to be applied to all states of this component.
    Gets inline styles that are to be applied to the disabled state of this component.
    Gets inline styles that are to be applied to the pressed state of this component.
    Gets inline styles that are to be applied to the selected state of this component.
    Gets the theme that is used by inline styles to reference images.
    Gets inline styles that are to be applied to the unselected state of this component.
    int
    Gets the inner height of this component.
    int
    Gets the preferred height removing vertical padding.
    int
    Gets the preferred width removing horizontal padding.
    int
    Gets the inner width of this component.
    int
    Gets x-coordinate of the inner bounds of this component.
    int
    Gets the inner y-coordinate of the inner bounds of this component.
    Allows us to indicate the label associated with this component thus providing visual feedback related for this component e.g.
    A component name allows us to easily identify the component within a dynamic UI.
    Gets the native overlay for this component.
    Allows us to determine which component will receive focus next when traversing with the down key
    Allows us to determine which component will receive focus next when traversing with the left key.
    Allows us to determine which component will receive focus next when traversing with the right key
    Allows us to determine which component will receive focus next when traversing with the up key.
    int
    Gets the outer height of this component.
    int
    Gets the preferred height including the vertical margins.
    int
    Gets the preferred width including horizontal margins.
    int
    Gets the outer width of this component.
    int
    Gets the x-coordinate of the outer bounds of this component.
    int
    Gets the Y-coordinate of the outer bounds of this component.
    Gets the "owner" of this component as set by #setOwner(com.codename1.ui.Component).
    Returns the container in which this component is contained
    int
    Helper method to retrieve the preferred height of the component.
    Returns the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size.
    Returns the preferred size string that can be used to specify the preferred size of the component using pixels or millimetres.
    int
    Gets the preferred tab index of this component.
    int
    Helper method to retrieve the preferred width of the component.
    Returns the Component Style for the pressed state allowing us to manipulate the look of the component when it is pressed
    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
    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[],Image,Image[],Object[],ListModel,ListCellRenderer
    Matches the property names method (see that method for further details).
    Returns the current value of the property name, this method is used by the GUI builder
    Returns the array of components that have an equal height
    Returns the array of components that have an equal width
    Returns the scrollable parent of this component
    int
    Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode
    Returns the Components dimension in scrolling, this is very similar to the preferred size aspect only it represents actual scrolling limits.
    int
    This method is used internally by the look and feel to implement the fading scrollbar behavior.
    int
    Indicates the decrement units for the scroll opacity
    int
    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.
    int
    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.
    Allows determining the text for the select command used in the 3rd softbutton mode.
    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 is useful for things such as the popup dialog and similar UI's that need to reference the position of the selection externally
    Returns the Component Style for the selected state allowing us to manipulate the look of the component when it owns focus
    int
    Returns the gap to be left for the side scrollbar on the Y axis.
    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.
    int
    Gets the tab index of the component.
    int
    Recommended length for the tensile, -1 for default
    Returns text selection support object for this component.
    Returns
    final String
    Unique identifier for a component.
    This method should be used by the Component to retrieve the correct UIManager to work with
    final Style
    Returns the Component Style for the unselected mode allowing us to manipulate the look of the component
    protected Rectangle
    Returns the component bounds for scrolling which might differ from the getBounds for large components e.g.
    Returns the component bounds for scrolling which might differ from the getBounds for large components into the provided rectangle.
    int
    Returns the component width
    int
    Returns the current component x location relatively to its parent container
    int
    Returns the component y location relatively to its parent container
    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.
    boolean
    Prevents key events from being grabbed for focus traversal.
    boolean
    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.
    boolean
    Returns true if the component has focus
    protected void
    Hides the native overlay for this component.
    protected void
    Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
    protected void
    Allows components to create a style of their own, this method binds the listener to the style and installs a bg painter
    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
    This method initializes the Component defaults constants
    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
    initSelectedStyle(Style selectedStyle)
    Can be overridden by subclasses to perform initialization when the selected style is set to a new value.
    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
    Allows subclasses to create their own custom style types and install the background painter into them
    boolean
    Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)
    boolean
    Prevent a lead component hierarchy from this specific component, this allows a component within that hierarchy to still act as a standalone component
    boolean
    Used as an optimization to mark that this component is currently being used as a cell renderer
    boolean
    Searches the hierarchy of the component recursively to see if the given Container is one of the parents of this component
    protected boolean
    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 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"
    boolean
    Indicates whether this component can be dragged in a drag and drop operation rather than scroll the parent
    protected boolean
    isDragRegion(int x, int y)
    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.
    boolean
    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
    boolean
    Checks to see if the component is editable.
    boolean
    Checks if the component is currently being edited.
    boolean
    Indicates whether component is enabled or disabled thus allowing us to prevent a component from receiving input events and indicate so visually
    boolean
    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.
    boolean
    Returns true if this component can receive focus and is enabled
    boolean
    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.
    boolean
    Returns true if the component was explicitly hidden by the user.
    boolean
    isHidden(boolean checkParent)
    Checks if the component is hidden.
    boolean
    Indicates that this component and all its children should be hidden when the device is switched to landscape mode
    boolean
    Indicates that this component and all its children should be hidden when the device is switched to portrait mode
    boolean
    Returns
    protected boolean
     
    protected boolean
    Indicates if the component is in the initialized state, a component is initialized when its initComponent() method was invoked.
    boolean
    Checks whether the component's background should be painted.
    boolean
    Checks to see if this component is owned by the given other component.
    boolean
    returns true if pinch will block drag and drop
    boolean
    Indicates whether the component displays the material design ripple effect
    final boolean
    Is the component a bidi RTL component
    protected boolean
    Indicates whether the component should/could scroll by default a component is not scrollable.
    boolean
    Indicates whether the component should/could scroll on the X axis
    boolean
    Indicates whether the component should/could scroll on the Y axis
    boolean
    Indicate whether this component scroll is visible
    protected boolean
    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.
    static boolean
    Checks to see if this platform supports cursors.
    boolean
    Indicates that scrolling through the component should work as an animation
    boolean
    Indicates whether scrolling this component should jump to a specific location in a grid
    protected boolean
    Returns true if the component is interested in receiving drag/pointer release events even after the gesture exceeded its boundaries.
    boolean
    Indicates whether the component should "trigger" tactile touch when pressed by the user in a touch screen UI.
    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
    boolean
    Indicates whether tensile drag (dragging beyond the boundry of the component and snapping back) is enabled for this component.
    final boolean
    Checks if this component should be traversable using the keyboard using tab, next, previous keys.
    boolean
    Returns whether the component is visible or not
    void
    keyPressed(int keyCode)
    If this Component is focused, the key pressed event will call this method
    void
    keyReleased(int keyCode)
    If this Component is focused, the key released event will call this method
    void
    keyRepeated(int keyCode)
    If this Component is focused, the key repeat event will call this method.
    protected void
    This is a callback method to inform the Component when it's been laidout on the parent Container
    protected void
    longKeyPress(int keyCode)
    If this Component is focused this method is invoked when the user presses and holds the key
    void
    longPointerPress(int x, int y)
    If this Component is focused this method is invoked when the user presses and holds the pointer on the Component
    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.
    protected void
    onSetFocusable(boolean focusable)
    Since setFocusable is final this callback is invoked when focusable changes.
    void
    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 void
    This method paints the Component background, it should be overriden by subclasses to perform custom background drawing.
    void
    This method paints all the parents Components Background.
    protected void
    Draws the component border if such a border exists.
    protected void
    Draws the component border background if such a border exists.
    final void
    Paints this component as a root by going to all the parent components and setting the absolute translation based on coordinates and scroll status.
    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.
    void
    Paints intersecting components that appear above this component.
    paintLock(boolean hardLock)
    This method locks the component so it will always paint the given image instead of running through its paint logic.
    void
    Releases the paint lock image to allow paint to work as usual, see paintLock(boolean) for details
    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.
    protected void
    Paints the UI for the scrollbars on the component, this will be invoked only for scrollable components.
    protected void
    Paints the UI for the scrollbar on the X axis, this method allows component subclasses to customize the look of a scrollbar
    protected void
    Paints the UI for the scrollbar on the Y axis, this method allows component subclasses to customize the look of a scrollbar
    void
    paintShadows(Graphics g, int relativeX, int relativeY)
    Paints the drop-shadow projections for this component based on its elevation value.
    protected String
    Returns a string representing the state of this component.
    static Dimension
    parsePreferredSize(String preferredSize, Dimension baseSize)
    Parses the preferred size given as a string
    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 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 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).
    void
    pointerDragged(int[] x, int[] y)
    If this Component is focused, the pointer dragged event will call this method
    void
    pointerDragged(int x, int y)
    If this Component is focused, the pointer dragged event will call this method
    void
    pointerHover(int[] x, int[] y)
    Invoked for devices where the pointer can hover without actually clicking the display.
    void
    pointerHoverPressed(int[] x, int[] y)
    Invoked for devices where the pointer can hover without actually clicking the display.
    void
    pointerHoverReleased(int[] x, int[] y)
    Invoked for devices where the pointer can hover without actually clicking the display.
    void
    pointerPressed(int[] x, int[] y)
    If this Component is focused, the pointer pressed event will call this method
    void
    pointerPressed(int x, int y)
    If this Component is focused, the pointer pressed event will call this method
    void
    pointerReleased(int[] x, int[] y)
    If this Component is focused, the pointer released event will call this method
    void
    pointerReleased(int x, int y)
    If this Component is focused, the pointer released event will call this method
    void
    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.
    void
    Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!
    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
    void
    This method will remove the Component from its parent.
    void
    Removes the listener from the drag finished event
    void
    Removes an action listener to drag over events
    void
    Removes an action listener to drop events which are invoked when this component is dropped on a target
    void
    Deregisters interest in receiving callbacks for focus gained events
    void
    Removes the listener from the pointer event
    void
    Removes the listener from the pointer event
    void
    Removes the listener from the pointer event
    void
    Removes the listener from the pointer event
    void
    Deregisters interest in receiving callbacks for scroll gained events
    void
    Removes a listener from being notified when the state of this component is changed to and from initialized.
    void
    Repaint this Component, the repaint call causes a callback of the paint method on the event dispatch thread.
    void
    repaint(int x, int y, int w, int h)
    Repaints a specific region within the component
    void
    Changes the current component to the focused component, will work only for a component that belongs to a parent form.
    protected void
    Restores the state of the focusable flag to its default state
    boolean
    Checks if the component responds to pointer events.
    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
    scrollRectToVisible(Rectangle rect, Component coordinateSpace)
    Makes sure the component is visible in the scroll if this container is scrollable
    void
    Sets the text that describes this component to assistive technologies.
    void
    setAlwaysTensile(boolean alwaysTensile)
    Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)
    void
    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
    void
    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!
    void
    setCellRenderer(boolean cellRenderer)
    Used as an optimization to mark that this component is currently being used as a cell renderer
    void
    setCloudBoundProperty(String cloudBoundProperty)
    Indicates the property within this component that should be bound to the cloud object
    void
    setCloudDestinationProperty(String cloudDestinationProperty)
    The destination property of the CloudObject
    void
    If getComponentState returned a value the setter can update the value and restore the prior state.
    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.
    static void
    setDefaultDragTransparency(byte defaultDragTransparency)
    Sets the default translucency of the #getDragImage() method.
    final void
    sets the Component dirty region, this method is for internal use only and SHOULD NOT be invoked by user code.
    void
    Changes the Component disalbed Style by replacing the Component Style with the given Style
    void
    setDraggable(boolean draggable)
    Indicates whether this component can be dragged in a drag and drop operation rather than scroll the parent
    void
    setDragTransparency(byte dragTransparency)
    Sets the translucency of the #getDragImage() method.
    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
    void
    Sets the editing delegate for this component.
    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
    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.
    void
    setFocus(boolean focused)
    This flag doesn't really give focus, its a state that determines what colors from the Style should be used when painting the component.
    final void
    setFocusable(boolean focusable)
    A simple setter to determine if this Component can get focused
    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.
    void
    setHandlesInput(boolean handlesInput)
    Prevents key events from being grabbed for focus traversal.
    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.
    void
    setHidden(boolean b)
    Makes the components preferred size equal 0 when hidden and restores it to the default size when not.
    void
    setHidden(boolean b, boolean changeMargin)
    Makes the components preferred size equal 0 when hidden and restores it to the default size when not.
    void
    setHideInLandscape(boolean hideInLandscape)
    Indicates that this component and all its children should be hidden when the device is switched to landscape mode
    void
    setHideInPortrait(boolean hideInPortrait)
    Indicates that this component and all its children should be hidden when the device is switched to portrait mode
    void
    setIgnorePointerEvents(boolean ignorePointerEvents)
    Parameters
    protected void
    setInitialized(boolean initialized)
    Indicates if the component is in the initialized state, a component is initialized when its initComponent() method was invoked.
    void
    Registers inline styles that should be applied to all states of the component.
    void
    Registers inline styles that should be applied to the disabled state of the component.
    void
    Registers inline styles that should be applied to the pressed state of the component.
    void
    Registers inline styles that should be applied to the selected state of the component.
    void
    setInlineStylesTheme(Resources inlineStylesTheme)
    Sets the theme that is used by inline styles to reference images.
    void
    Registers inline styles that should be applied to the unselected state of the component.
    void
    setIsScrollVisible(boolean isScrollVisible)
    Set whether this component scroll is visible
    void
    setLabelForComponent(Label componentLabel)
    Allows us to indicate the label associated with this component thus providing visual feedback related for this component e.g.
    void
    A component name allows us to easily identify the component within a dynamic UI.
    void
    setNextFocusDown(Component nextFocusDown)
    Allows us to determine which component will receive focus next when traversing with the down key
    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.
    void
    setNextFocusRight(Component nextFocusRight)
    Allows us to determine which component will receive focus next when traversing with the right key
    void
    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.
    final void
    setOpaque(boolean opaque)
    Sets whether or not to paint the component background.
    void
    Sets the owner of this component to the specified component.
    void
    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).
    void
    setPreferredH(int preferredH)
    Helper method to set the preferred height of the component.
    void
    Sets the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size.
    void
    Parameters
    void
    Sets the preferred tab index of the component.
    void
    setPreferredW(int preferredW)
    Helper method to set the preferred width of the component.
    void
    Sets the Component Style for the pressed state allowing us to manipulate the look of the component when it is pressed
    Sets a new value to the given property, returns an error message if failed and null if successful.
    void
    setRippleEffect(boolean rippleEffect)
    Indicates whether the component displays the material design ripple effect
    void
    setRTL(boolean rtl)
    Is the component a bidi RTL component
    static void
    Places all of these components in the same height group, to remove a component from the group invoke this method with that component only.
    static void
    This is identical to invoking #sameWidth followed by #sameHeight
    static void
    Places all of these components in the same width group, to remove a component from the group invoke this method with that component only.
    void
    setScrollAnimationSpeed(int animationSpeed)
    Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode
    void
    setScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed)
    Indicates the decrement units for the scroll opacity
    void
    Set the size for the scroll area
    void
    setScrollVisible(boolean isScrollVisible)
    Set whether this component scroll is visible
    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.
    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.
    void
    Allows determining the text for the select command used in the 3rd softbutton mode.
    void
    Changes the Component selected Style by replacing the Component Style with the given Style
    void
    setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)
    Indicates the values within the component have changed and preferred size should be recalculated
    void
    Sets the Component size, this method is exposed for the purpose of external layout managers and should not be invoked directly.
    void
    setSmoothScrolling(boolean smoothScrolling)
    Indicates that scrolling through the component should work as an animation
    void
    setSnapToGrid(boolean snapToGrid)
    Indicates whether scrolling this component should jump to a specific location in a grid
    void
    setTabIndex(int index)
    Sets the tab index of the component.
    void
    setTactileTouch(boolean tactileTouch)
    Indicates whether the component should "trigger" tactile touch when pressed by the user in a touch screen UI.
    void
    setTensileDragEnabled(boolean tensileDragEnabled)
    Indicates whether tensile drag (dragging beyond the boundry of the component and snapping back) is enabled for this component.
    void
    setTensileLength(int tensileLength)
    Recommended length for the tensile, -1 for default
    void
    setTooltip(String tooltip)
    Parameters
    final void
    setTraversable(boolean traversable)
    Sets whether this component is traversable using the keyboard using tab, next, previous keys.
    void
    This method sets the Component the Unique identifier.
    void
    setUIID(String portraitUiid, String landscapeUiid)
    This method sets the Component the Unique identifier.
    protected final void
    This method is the implementation of setUIID and is defined as final to allow invocation from constructors.
    void
    Changes the Component Style by replacing the Component Style with the given Style
    void
    setVisible(boolean visible)
    Toggles visibility of the component
    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.
    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.
    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.
    protected boolean
    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
    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
    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
    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.
    protected void
    Creates the native overlay for this component.
    void
    If the component #isEditable(), then this will start the editing process.
    void
    Stops the editing process.
    Convenience method that strips margin and padding from the component, and returns itself for chaining.
    void
    styleChanged(String propertyName, Style source)
    Invoked to indicate a change in a propertyName of a Style
    Returns the component as an image.
    Overriden to return a useful value for debugging purposes
    void
    Removes a bind target from the given property name
    protected void
    Updates the native overlay for this component.
    boolean
    visibleBoundsContains(int x, int y)
    Returns true if the given absolute coordinate is contained inside the visible bounds of the component.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_CURSOR

      public static final int DEFAULT_CURSOR
      The default cursor
      See Also:
    • CROSSHAIR_CURSOR

      public static final int CROSSHAIR_CURSOR
      The crosshair cursor type.
      See Also:
    • TEXT_CURSOR

      public static final int TEXT_CURSOR
      The text cursor type.
      See Also:
    • WAIT_CURSOR

      public static final int WAIT_CURSOR
      The wait cursor type.
      See Also:
    • SW_RESIZE_CURSOR

      public static final int SW_RESIZE_CURSOR
      The south-west-resize cursor type.
      See Also:
    • SE_RESIZE_CURSOR

      public static final int SE_RESIZE_CURSOR
      The south-east-resize cursor type.
      See Also:
    • NW_RESIZE_CURSOR

      public static final int NW_RESIZE_CURSOR
      The north-west-resize cursor type.
      See Also:
    • NE_RESIZE_CURSOR

      public static final int NE_RESIZE_CURSOR
      The north-east-resize cursor type.
      See Also:
    • N_RESIZE_CURSOR

      public static final int N_RESIZE_CURSOR
      The north-resize cursor type.
      See Also:
    • S_RESIZE_CURSOR

      public static final int S_RESIZE_CURSOR
      The south-resize cursor type.
      See Also:
    • W_RESIZE_CURSOR

      public static final int W_RESIZE_CURSOR
      The west-resize cursor type.
      See Also:
    • E_RESIZE_CURSOR

      public static final int E_RESIZE_CURSOR
      The east-resize cursor type.
      See Also:
    • HAND_CURSOR

      public static final int HAND_CURSOR
      The hand cursor type.
      See Also:
    • MOVE_CURSOR

      public static final int MOVE_CURSOR
      The move cursor type.
      See Also:
    • DRAG_REGION_NOT_DRAGGABLE

      public static final int DRAG_REGION_NOT_DRAGGABLE
      Used by getDragRegionStatus to indicate no dragability
      See Also:
    • DRAG_REGION_POSSIBLE_DRAG_X

      public static final int DRAG_REGION_POSSIBLE_DRAG_X
      Used by getDragRegionStatus to indicate limited dragability
      See Also:
    • DRAG_REGION_POSSIBLE_DRAG_Y

      public static final int DRAG_REGION_POSSIBLE_DRAG_Y
      Used by getDragRegionStatus to indicate limited dragability
      See Also:
    • DRAG_REGION_POSSIBLE_DRAG_XY

      public static final int DRAG_REGION_POSSIBLE_DRAG_XY
      Used by getDragRegionStatus to indicate limited dragability
      See Also:
    • DRAG_REGION_LIKELY_DRAG_X

      public static final int DRAG_REGION_LIKELY_DRAG_X
      Used by getDragRegionStatus to indicate likely dragability
      See Also:
    • DRAG_REGION_LIKELY_DRAG_Y

      public static final int DRAG_REGION_LIKELY_DRAG_Y
      Used by getDragRegionStatus to indicate likely dragability
      See Also:
    • DRAG_REGION_LIKELY_DRAG_XY

      public static final int DRAG_REGION_LIKELY_DRAG_XY
      Used by getDragRegionStatus to indicate likely dragability
      See Also:
    • DRAG_REGION_IMMEDIATELY_DRAG_X

      public static final int DRAG_REGION_IMMEDIATELY_DRAG_X
      Used by getDragRegionStatus to indicate immediate dragability
      See Also:
    • DRAG_REGION_IMMEDIATELY_DRAG_Y

      public static final int DRAG_REGION_IMMEDIATELY_DRAG_Y
      Used by getDragRegionStatus to indicate immediate dragability
      See Also:
    • DRAG_REGION_IMMEDIATELY_DRAG_XY

      public static final int DRAG_REGION_IMMEDIATELY_DRAG_XY
      Used by getDragRegionStatus to indicate immediate dragability
      See Also:
    • BRB_CONSTANT_ASCENT

      public static final int BRB_CONSTANT_ASCENT

      Baseline resize behavior constant used to properly align components. Indicates as the size of the component changes the baseline remains a fixed distance from the top of the component.

      See also
      • #getBaselineResizeBehavior
      See Also:
    • BRB_CONSTANT_DESCENT

      public static final int BRB_CONSTANT_DESCENT

      Baseline resize behavior constant used to properly align components. Indicates as the size of the component changes the baseline remains a fixed distance from the bottom of the component.

      See also
      • #getBaselineResizeBehavior
      See Also:
    • BRB_CENTER_OFFSET

      public static final int BRB_CENTER_OFFSET

      Baseline resize behavior constant used to properly align components. Indicates as the size of the component changes the baseline remains a fixed distance from the center of the component.

      See also
      • #getBaselineResizeBehavior
      See Also:
    • BRB_OTHER

      public static final int BRB_OTHER

      Baseline resize behavior constant used to properly align components. Indicates as the size of the component changes the baseline can not be determined using one of the other constants.

      See also
      • #getBaselineResizeBehavior
      See Also:
    • CENTER

      public static final int CENTER
      Indicates a Component center alignment
      See Also:
    • TOP

      public static final int TOP
      Box-orientation constant used to specify the top of a box.
      See Also:
    • LEFT

      public static final int LEFT
      Box-orientation constant used to specify the left side of a box.
      See Also:
    • BOTTOM

      public static final int BOTTOM
      Box-orientation constant used to specify the bottom of a box.
      See Also:
    • BASELINE

      public static final int BASELINE
      Alignment to the baseline constraint
      See Also:
  • Constructor Details

    • Component

      protected Component()
      Creates a new instance of Component
  • Method Details

    • setSameSize

      public static void setSameSize(Component... c)

      This is identical to invoking #sameWidth followed by #sameHeight

      Parameters
      • c: the components to group together, this will override all previous width/height grouping
    • isSetCursorSupported

      public static boolean isSetCursorSupported()

      Checks to see if this platform supports cursors. If the platform doesn't support cursors then any cursors set with #setCursor(int) will simply be ignored.

      Returns

      True if the platform supports custom cursors.

    • parsePreferredSize

      public static Dimension parsePreferredSize(String preferredSize, Dimension baseSize)

      Parses the preferred size given as a string

      Parameters
      • preferredSize: a string representing a width/height preferred size using common units e.g. mm, px etc.

      • baseSize: used as the starting point for the calculation, typically the preferred size of the component

      Returns

      the parsed results

    • getDefaultDragTransparency

      public static byte getDefaultDragTransparency()

      Returns the default translucency used in the #getDragImage() method.

      Returns

      a number between 0 and 255 where 255 indicates an opaque image.

    • setDefaultDragTransparency

      public static void setDefaultDragTransparency(byte defaultDragTransparency)

      Sets the default translucency of the #getDragImage() method.

      Parameters
      • defaultDragTransparency: @param defaultDragTransparency a number between 0 and 255 where 255 indicates an opaque image.
    • getEditingDelegate

      public Editable getEditingDelegate()

      Gets the delegate that handles the editing of this component.

      Returns

      The editing delegate for this component.

      Since

      6.0

    • setEditingDelegate

      public void setEditingDelegate(Editable editable)

      Sets the editing delegate for this component. The editing delegate allows you to define the editing workflow for a component. If a delegate is registered, then editing methods such as #isEditable(), #isEditing(), #startEditingAsync(), and #stopEditing(java.lang.Runnable) will be delegated to the delegate object.

      Parameters
      • editable: An editable delegate.
      Since

      6.0

    • getCursor

      public int getCursor()

      Gets the custom cursor for this component. This will only be used if the platform supports custom cursors. You can call #isSetCursorSupported() to find out.

      Returns
      Returns:
      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.
    • 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
      • cursor: @param cursor 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.
      See also
      • Form#setEnableCursors(boolean)

      • Form#isEnableCursors()

    • showNativeOverlay

      protected void showNativeOverlay()

      Creates the native overlay for this component. A native overlay is used on some platforms (e.g. Javascript) to help with user interaction of the component in a native way.

      See also
      • #hideNativeOverlay()

      • #updateNativeOverlay()

      • #getNativeOverlay()

    • hideNativeOverlay

      protected void hideNativeOverlay()

      Hides the native overlay for this component.

      See also
      • #showNativeOverlay()

      • #updateNativeOverlay()

      • #getNativeOverlay()

    • updateNativeOverlay

      protected void updateNativeOverlay()

      Updates the native overlay for this component. This is called each time the component is laid out, so it can change the position and visibility to match the current context.

      See also
      • #showNativeOverlay()

      • #hideNativeOverlay()

      • #getNativeOverlay()

    • getNativeOverlay

      public Object getNativeOverlay()

      Gets the native overlay for this component. May be null. Native overlays are used in the Javascript port to assist with user interaction on touch devices. Text fields use native overlays to position an invisible native text field above themselves so that the keyboard will be activated properly when the user taps the text field.

      Returns

      The native overlay

    • 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:

      Painter p = new Painter(cmp) {
          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;
              switch (style) {
                  case CircleButtonStrokedDark:
                  case CircleButtonStrokedLight: {
                      if (cmp.getStyle().getBgTransparency() != 0) {
                          int alpha = cmp.getStyle().getBgTransparency();
                          if (alpha <0) {
                              alpha = 0xff;
                          }
                          g.setColor(cmp.getStyle().getBgColor());
                          g.setAlpha(alpha);
                          g.fillArc(x, y, 2*r-1, 2*r-1, 0, 360);
                          g.setAlpha(0xff);
                      }
                      g.setColor(cmp.getStyle().getFgColor());
                      g.drawArc(x, y, 2*r-1, 2*r-1, 0, 360);
                      break;
                  }
                  case CircleButtonFilledDark:
                  case CircleButtonFilledLight:
                  case CircleButtonTransparentDark:
                  case CircleButtonTransparentLight: {
                      int alpha = cmp.getStyle().getBgTransparency();
                      if (alpha < 0) {
                          alpha = 0xff;
                      }
                      g.setAlpha(alpha);
                      g.setColor(cmp.getStyle().getBgColor());
                      g.fillArc(x, y, 2*r, 2*r, 0, 360);
                      g.setAlpha(0xff);
                      break;
                  }
              }
      
              g.setAntiAliased(antiAliased);
          }
      };
      cmp.getAllStyles().setBgPainter(p);
      
      Returns

      a unified style object to set values on all styles

    • getSameWidth

      public Component[] getSameWidth()

      Returns the array of components that have an equal width

      Returns

      components in the same width group

    • setSameWidth

      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.

      Parameters
      • c: the components to group together, this will override all previous width grouping
    • getSameHeight

      public Component[] getSameHeight()

      Returns the array of components that have an equal height

      Returns

      components in the same height group

    • setSameHeight

      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.

      Parameters
      • c: the components to group together, this will override all previous height grouping
    • initLaf

      protected void initLaf(UIManager uim)
      This method initializes the Component defaults constants
    • getUIManager

      public UIManager getUIManager()

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

      Returns

      a UIManager instance

    • getX

      public int getX()

      Returns the current component x location relatively to its parent container

      Returns

      the current x coordinate of the components origin

    • setX

      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.

      Parameters
      • x: the current x coordinate of the components origin
    • getOuterX

      public int getOuterX()

      Gets the x-coordinate of the outer bounds of this component. The outer bounds are formed by the bounds outside the margin of the component. (i.e. x - leftMargin).

      Returns

      The outer X bound.

    • getInnerX

      public int getInnerX()

      Gets x-coordinate of the inner bounds of this component. The inner bounds are formed by the bounds of the padding of the component. i.e. x + leftPadding.

      Returns

      The inner x bound.

    • getY

      public int getY()

      Returns the component y location relatively to its parent container

      Returns

      the current y coordinate of the components origin

    • setY

      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.

      Parameters
      • y: the current y coordinate of the components origin
    • getOuterY

      public int getOuterY()

      Gets the Y-coordinate of the outer bounds of this component. The outer bounds are formed by the bound of the margin of the component. i.e. y - leftMargin.

      Returns

      The outer y bound.

    • getInnerY

      public int getInnerY()

      Gets the inner y-coordinate of the inner bounds of this component. The inner bounds are formed by the bound of the padding of the component. i.e. y + leftPadding.

      Returns

      The inner y bound.

    • isVisible

      public boolean isVisible()

      Returns whether the component is visible or not

      Returns

      true if component is visible; otherwise false

    • setVisible

      public void setVisible(boolean visible)

      Toggles visibility of the component

      Parameters
      • visible: true if component is visible; otherwise false
    • getClientProperty

      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.

      Parameters
      • key: the key used for putClientProperty
      Returns

      the value set to putClientProperty or null if no value is set to the property

    • stripMarginAndPadding

      public Component stripMarginAndPadding()

      Convenience method that strips margin and padding from the component, and returns itself for chaining.

      Returns

      Self for chaining.

      Since

      7.0

      See also
      • Style#stripMarginAndPadding()
    • clearClientProperties

      public void clearClientProperties()
      Clears all client properties from this Component
    • putClientProperty

      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. Setting the value to null will remove the client property from the component.

      Parameters
      • key: arbitrary key for the property

      • value: the value assigned to the given client property

    • getDirtyRegion

      public final Rectangle getDirtyRegion()

      gets the Component dirty region, this method is for internal use only and SHOULD NOT be invoked by user code. Use repaint(int,int,int,int)

      Returns

      returns the region that needs repainting or null for the whole component

    • setDirtyRegion

      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. Use repaint(int,int,int,int)

      Parameters
      • dirty: the region that needs repainting or null for the whole component
    • isOpaque

      public boolean isOpaque()

      Checks whether the component's background should be painted.

      Returns

      true if the component's background should be painted.

    • setOpaque

      public final void setOpaque(boolean opaque)

      Sets whether or not to paint the component background. Default is true

      Parameters
      • opaque: False to not paint the component's background.
      Since

      6.0

    • getWidth

      public int getWidth()

      Returns the component width

      Returns

      the component width

    • 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
      • width: the width of the component
      See also
      • #setPreferredSize
    • getOuterWidth

      public int getOuterWidth()

      Gets the outer width of this component. This is the width of the component including horizontal margins.

      Returns

      The outer width.

    • getInnerWidth

      public int getInnerWidth()

      Gets the inner width of this component. This is the width of the component removing horizontal padding.

      Returns

      The inner width.

    • getHeight

      public int getHeight()

      Returns the component height

      Returns

      the component height

    • 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
      • height: the height of the component
      See also
      • #setPreferredSize
    • getOuterHeight

      public int getOuterHeight()

      Gets the outer height of this component. This is the height of the component including vertical margins.

      Returns

      The outer height.

    • getInnerHeight

      public int getInnerHeight()

      Gets the inner height of this component. This is the height of the component removing vertical padding.

      Returns

      The inner height.

    • isDragRegion

      protected boolean isDragRegion(int x, int y)

      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. This is invoked by the implementation code to optimize drag start behavior

      Parameters
      • x: x location for the touch

      • y: y location for the touch

      Returns

      true if the touch is in a region specifically designated as a "drag region"

      Deprecated

      replaced with getDragRegionStatus

    • getDragRegionStatus

      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. This is invoked by the implementation code to optimize drag start behavior

      Parameters
      • x: x location for the touch

      • y: y location for the touch

      Returns

      one of the DRAG_REGION_* values

    • getBaseline

      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.

      Parameters
      • width: the component width

      • height: the component height

      Returns

      baseline value from the top of the component

    • getBaselineResizeBehavior

      public int getBaselineResizeBehavior()

      Returns a constant indicating how the baseline varies with the size of the component.

      Returns
      Returns:
      one of BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET or BRB_OTHER
    • getPreferredSizeStr

      public String getPreferredSizeStr()

      Returns the preferred size string that can be used to specify the preferred size of the component using pixels or millimetres. This string is applied to the preferred size just after is is initially calculated using #calcPreferredSize().

      Returns

      the preferred size string

      Deprecated
    • setPreferredSizeStr

      public void setPreferredSizeStr(String value)
      Parameters
      • value: @param value 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.
      Deprecated
    • 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

      the component preferred size

    • 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
      • d: the component dimension
      Deprecated
    • getScrollDimension

      public Dimension getScrollDimension()

      Returns the Components dimension in scrolling, this is very similar to the preferred size aspect only it represents actual scrolling limits.

      Returns

      the component actual size with all scrolling

    • calcScrollSize

      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

      Returns

      scroll size, by default this is the same as the preferred size

    • setScrollSize

      public void setScrollSize(Dimension d)

      Set the size for the scroll area

      Parameters
      • d: dimension of the scroll area
    • getPreferredW

      public int getPreferredW()

      Helper method to retrieve the preferred width of the component.

      Returns

      preferred width of the component

      See also
      • #getPreferredSize
    • setPreferredW

      public void setPreferredW(int preferredW)

      Helper method to set the preferred width of the component.

      Parameters
      • preferredW: the preferred width of the component
      Deprecated
    • getPreferredH

      public int getPreferredH()

      Helper method to retrieve the preferred height of the component.

      Returns

      preferred height of the component

      See also
      • #getPreferredSize
    • setPreferredH

      public void setPreferredH(int preferredH)

      Helper method to set the preferred height of the component.

      Parameters
      • preferredH: the preferred height of the component
      Deprecated
    • getOuterPreferredH

      public int getOuterPreferredH()

      Gets the preferred height including the vertical margins.

      Returns

      The preferred outer height.

    • getInnerPreferredH

      public int getInnerPreferredH()

      Gets the preferred height removing vertical padding.

      Returns

      The preferred inner height.

    • getOuterPreferredW

      public int getOuterPreferredW()

      Gets the preferred width including horizontal margins.

      Returns

      The preferred outer width.

    • getInnerPreferredW

      public int getInnerPreferredW()

      Gets the preferred width removing horizontal padding.

      Returns

      preferred width

    • 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
      • d: the component dimension
      See also
      • #setPreferredSize
    • getUIID

      public final String getUIID()

      Unique identifier for a component. This id is used to retrieve a suitable Style.

      Returns

      unique string identifying this component for the style sheet

    • setUIID

      public void setUIID(String id)

      This method sets the Component the Unique identifier. This method should be used before a component has been initialized

      Parameters
      • id: UIID unique identifier for component type
    • setUIIDFinal

      protected final void setUIIDFinal(String id)

      This method is the implementation of setUIID and is defined as final to allow invocation from constructors.

      Parameters
      • id: UIID unique identifier for component type
    • setUIID

      public void setUIID(String portraitUiid, String landscapeUiid)

      This method sets the Component the Unique identifier.

      Parameters
      • portraitUiid: UIID unique identifier for component type in portrait mode

      • landscapeUiid: UIID unique identifier for component type in landscape mode

    • getInlineAllStyles

      public String getInlineAllStyles()

      Gets inline styles that are to be applied to all states of this component.

      Returns

      Inline styles applied to all states.

    • setInlineAllStyles

      public void setInlineAllStyles(String styles)

      Registers inline styles that should be applied to all states of the component.

      Parameters
      • styles: a style in the format of "fgColor:ff0000; font:18mm; border: 1px solid ff0000; bgType:none; padding: 3mm; margin: 1mm"
    • getInlineSelectedStyles

      public String getInlineSelectedStyles()

      Gets inline styles that are to be applied to the selected state of this component.

      Returns

      Inline styles applied to selected state

    • setInlineSelectedStyles

      public void setInlineSelectedStyles(String styles)

      Registers inline styles that should be applied to the selected state of the component.

      Parameters
      • styles: style format
      See also
      • #setInlineAllStyles(String)
    • getInlineUnselectedStyles

      public String getInlineUnselectedStyles()

      Gets inline styles that are to be applied to the unselected state of this component.

      Returns

      Inline styles applied to unselected state

    • setInlineUnselectedStyles

      public void setInlineUnselectedStyles(String styles)

      Registers inline styles that should be applied to the unselected state of the component.

      Parameters
      • styles: style format
      See also
      • #setInlineAllStyles(String)
    • getInlineDisabledStyles

      public String getInlineDisabledStyles()

      Gets inline styles that are to be applied to the disabled state of this component.

      Returns

      Inline styles applied to disabled state

    • setInlineDisabledStyles

      public void setInlineDisabledStyles(String styles)

      Registers inline styles that should be applied to the disabled state of the component.

      Parameters
      • styles: style format
      See also
      • #setInlineAllStyles(String)
    • getInlinePressedStyles

      public String getInlinePressedStyles()

      Gets inline styles that are to be applied to the pressed state of this component.

      Returns

      Inline styles applied to pressed state

    • setInlinePressedStyles

      public void setInlinePressedStyles(String styles)

      Registers inline styles that should be applied to the pressed state of the component.

      Parameters
      • styles: style format
      See also
      • #setInlineAllStyles(String)
    • remove

      public void remove()
      This method will remove the Component from its parent.
    • getParent

      public Container getParent()

      Returns the container in which this component is contained

      Returns

      the parent container in which this component is contained

    • getOwner

      public Component getOwner()

      Gets the "owner" of this component as set by #setOwner(com.codename1.ui.Component).

      Returns

      The owner component or null.

      Since

      7.0

    • 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
      • owner: The component to set as the owner of this component.
      Since

      6.0

      See also
      • #isOwnedBy(com.codename1.ui.Component)

      • #containsOrOwns(int, int)

    • 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
      • cmp: the owner
      Returns

      True if this component is owned by cmp.

      Since

      6.0

      See also
      • #setOwner(com.codename1.ui.Component)

      • #containsOrOwns(int, int)

    • containsOrOwns

      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.

      Parameters
      • x: X-coordinate in absolute coordinates.

      • y: Y-coordinate in absolute coordinates.

      Returns
      Returns:

      True if the coordinate is either inside the bounds of this component or a component owned by this component.

      Since

      6.0

      See also
      • #setOwner(com.codename1.ui.Component)

      • #isOwnedBy(com.codename1.ui.Component)

    • addFocusListener

      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. A special case exists for the Form which sends a focus even for every selection within the form.

      Parameters
      • l: listener interface implementing the observable pattern
    • removeFocusListener

      public void removeFocusListener(FocusListener l)

      Deregisters interest in receiving callbacks for focus gained events

      Parameters
      • l: listener interface implementing the observable pattern
    • addScrollListener

      public void addScrollListener(ScrollListener l)

      Registers interest in receiving callbacks for scroll gained events, a scroll event is invoked when the component is scrolled.

      Parameters
      • l: listener interface implementing the observable pattern
    • removeScrollListener

      public void removeScrollListener(ScrollListener l)

      Deregisters interest in receiving callbacks for scroll gained events

      Parameters
      • l: listener interface implementing the observable pattern
    • fireClicked

      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. When overriding this method you should also override isSelectableInteraction to indicate that a command is placed appropriately on top of the fire key for 3 soft button phones.
    • isSelectableInteraction

      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.

      Returns

      true if this is a selectable interaction

    • getSelectCommandText

      public String getSelectCommandText()

      Allows determining the text for the select command used in the 3rd softbutton mode.

      Returns

      text for the interaction with the softkey

    • setSelectCommandText

      public void setSelectCommandText(String selectText)

      Allows determining the text for the select command used in the 3rd softbutton mode.

      Parameters
      • selectText: text for the interaction with the softkey
    • getLabelForComponent

      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.

      Returns

      the label associated with this component

    • setLabelForComponent

      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.

      Parameters
      • componentLabel: a label associated with this component
    • focusGained

      protected void focusGained()
      Callback allowing a developer to track when the component gains focus
    • focusLost

      protected void focusLost()
      Callback allowing a developer to track wheh the component loses focus
    • paintBackgrounds

      public void paintBackgrounds(Graphics g)

      This method paints all the parents Components Background.

      Parameters
      • g: 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
      • g: The graphics context onto which the shadow should be painted.

      • relativeX: The relative X coordinate onto which the shadow should be drawn.

      • relativeY: The relative Y coordinate onto which the shadow should be drawn.

      Since

      8.0

      See also
      • Container#paintElevatedPane(Graphics)

      • Container#isSurface()

      • Style#getElevation()

    • getAbsoluteX

      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()

      Returns

      the absolute x location of the component

      See also
      • #getX
    • getAbsoluteY

      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()

      Returns

      the absolute y location of the component

      See also
      • #getY
    • isInClippingRegion

      protected boolean isInClippingRegion(Graphics g)
    • paintIntersectingComponentsAbove

      public void paintIntersectingComponentsAbove(Graphics g)

      Paints intersecting components that appear above this component.

      Parameters
      • g: Graphics context
      Deprecated

      For internal use only

    • paintScrollbars

      protected void paintScrollbars(Graphics g)

      Paints the UI for the scrollbars on the component, this will be invoked only for scrollable components. This method invokes the appropriate X/Y versions to do all the work.

      Parameters
      • g: the component graphics
    • paintScrollbarX

      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

      Parameters
      • g: the component graphics
    • getScrollOpacity

      public int getScrollOpacity()

      This method is used internally by the look and feel to implement the fading scrollbar behavior.

      Returns

      the opacity of the scrollbar

    • getSelectedRect

      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 is useful for things such as the popup dialog and similar UI's that need to reference the position of the selection externally

      Returns

      the bounds of the component with absolute screen coordinates

    • paintScrollbarY

      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

      Parameters
      • g: 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
      • g: 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
      • g: the graphics to paint this Component on

      • background: if true paints all parents background

    • getBorder

      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

      Returns

      the border that is drawn according to the current component state

    • getScrollable

      public Component getScrollable()

      Returns the scrollable parent of this component

      Returns

      the component itself or its parent which is scrollable

    • paintBackground

      protected void paintBackground(Graphics g)

      This method paints the Component background, it should be overriden by subclasses to perform custom background drawing.

      Parameters
      • g: the component graphics
    • paint

      public void paint(Graphics g)

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

      Parameters
      • g: the component graphics
      Specified by:
      paint in interface Animation
    • isScrollable

      protected boolean isScrollable()

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

      Returns

      whether the component is scrollable

    • isScrollableX

      public boolean isScrollableX()

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

      Returns

      whether the component is scrollable on the X axis

    • isScrollableY

      public boolean isScrollableY()

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

      Returns

      whether the component is scrollable on the X axis

    • getScrollX

      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.

      Returns

      the X position of the scrolling

    • setScrollX

      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.

      Parameters
      • scrollX: the X position of the scrolling
    • getScrollY

      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.

      Returns

      the Y position of the scrolling

    • setScrollY

      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.

      Parameters
      • scrollY: the Y position of the scrolling
    • onScrollX

      protected void onScrollX(int scrollX)

      This method can be overriden to receive scroll events, unlike overriding setScrollX it will receive all calls for scrolling. Normally you should not override this method and try to find a more creative solution since scrolling is very specific to platform behavior.

      Parameters
      • scrollX: the X position of the scrolling
    • onScrollY

      protected void onScrollY(int scrollY)

      This method can be overriden to receive scroll events, unlike overriding setScrollY it will receive all calls for scrolling. Normally you should not override this method and try to find a more creative solution since scrolling is very specific to platform behavior.

      Parameters
      • scrollY: the Y position of the scrolling
    • getDraggedx

      public int getDraggedx()

      Gets the current dragged x values when the Component is being dragged

      Returns

      dragged x value

    • getDraggedy

      public int getDraggedy()

      Gets the current dragged y values when the Component is being dragged

      Returns

      dragged y value

    • getBottomGap

      public int getBottomGap()

      Returns the gap to be left for the bottom scrollbar on the X axis. This method is used by layout managers to determine the room they should leave for the scrollbar

      Returns

      the gap to be left for the bottom scrollbar on the X axis

    • getSideGap

      public int getSideGap()

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

      Returns

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

    • 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
      • x: the given absolute x coordinate

      • y: the given absolute y coordinate

      Returns
      Returns:

      true if the given absolute coordinate is contained in the Component; otherwise false

      See also
      • #visibleBoundsContains(int, int)
    • visibleBoundsContains

      public boolean visibleBoundsContains(int x, int y)

      Returns true if the given absolute coordinate is contained inside the visible bounds of the component. This differs from 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
      • x: the given absolute x coordinate

      • y: the given absolute y coordinate

      Returns
      Returns:

      true if the given absolute coordinate is contained in the Component's visible bounds; otherwise false

      See also
      • #contains(int, int)
    • calcPreferredSize

      protected Dimension calcPreferredSize()

      Calculates the preferred size based on component content. This method is invoked lazily by getPreferred size.

      Returns

      the calculated preferred size based on component content

    • hasFixedPreferredSize

      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.

      Returns

      True if this component has a fixed preferred size.

      Since

      7.0

    • 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

      the component bounds

      See also
      • #getX

      • #getY

      • #getBounds(com.codename1.ui.geom.Rectangle)

    • getBounds

      public Rectangle getBounds(Rectangle rect)

      Returns the bounds of this component in the provided Rectangle.

      Parameters
      • rect: An "out" parameter to store the component bounds in. Cannot be null.
      Returns

      The same Rectangle that was passed as a parameter.

      Since

      7.0

      See also
      • #getBounds()
    • getVisibleBounds

      protected Rectangle getVisibleBounds()

      Returns the component bounds for scrolling which might differ from the getBounds for large components e.g. list.

      Returns

      the component bounds

      See also
      • #getX

      • #getY

      • #getVisibleBounds(com.codename1.ui.geom.Rectangle)

    • getVisibleBounds

      public Rectangle getVisibleBounds(Rectangle rect)

      Returns the component bounds for scrolling which might differ from the getBounds for large components into the provided rectangle.

      Parameters
      • rect: An "out" parameter to store the bounds in. Cannot be null.
      Returns

      The same Rectangle that was passed as a parameter.

      Since

      7.0

      See also
      • #getVisibleBounds()
    • isFocusable

      public boolean isFocusable()

      Returns true if this component can receive focus and is enabled

      Returns

      true if this component can receive focus; otherwise false

    • setFocusable

      public final void setFocusable(boolean focusable)

      A simple setter to determine if this Component can get focused

      Parameters
      • focusable: indicate whether this component can get focused
    • onSetFocusable

      protected void onSetFocusable(boolean focusable)

      Since setFocusable is final this callback is invoked when focusable changes.

      Parameters
      • focusable: true if the component was made focusable
    • resetFocusable

      protected void resetFocusable()
      Restores the state of the focusable flag to its default state
    • getTabIndex

      public int getTabIndex()

      Gets the tab index of the component. This value is only useful immediately after calling Form#getTabIterator(com.codename1.ui.Component) on the form or Container#updateTabIndices(int) in the parent component.

      Returns

      The tab index of the component.

      Deprecated

      This method is used internally when querying the traversal order of the form. Use #getPreferredTabIndex() to get the preferred tab index.

      See also
      • #getPreferredTabIndex()

      • #setTabIndex(int)

      • #setPreferredTabIndex(int)

      • Form#getTabIterator(com.codename1.ui.Component)

      • Container#updateTabIndices(int)

    • setTabIndex

      public void setTabIndex(int index)

      Sets the tab index of the component. This method is for internal use only. To set the preferred tab index, use #setPreferredTabIndex(int)

      Parameters
      • index: The tab index.
      Deprecated

      This method is called internally by the layout manager each time the traversal order of the form is queried. Use #setPreferredTabIndex(int) instead.

      See also
      • #getPreferredTabIndex()

      • #setPreferredTabIndex(int)

      • #getTabIndex()

      • Form#getTabIterator(com.codename1.ui.Component)

    • 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

      the tabbing index

    • setPreferredTabIndex

      public void setPreferredTabIndex(int index)

      Sets the preferred tab index of the component.

      Parameters
      • index: The preferred tab index
      See also
      • #getPreferredTabIndex()

      • Form#getTabIterator(com.codename1.ui.Component)

      • Container#updateTabIndices(int)

    • 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

      true if traversable in tab indexing

    • 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
      • traversable: True to make the component traversable.
    • setShouldCalcPreferredSize

      public void setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)

      Indicates the values within the component have changed and preferred size should be recalculated

      Parameters
      • shouldCalcPreferredSize: @param shouldCalcPreferredSize indicate whether this component need to recalculate his preferred size
    • handlesInput

      public boolean handlesInput()

      Prevents key events from being grabbed for focus traversal. E.g. a list component might use the arrow keys for internal navigation so it will switch this flag to true in order to prevent the focus manager from moving to the next component.

      Returns
      Returns:
      true if key events are being used for focus traversal ; otherwise false
    • setHandlesInput

      public void setHandlesInput(boolean handlesInput)

      Prevents key events from being grabbed for focus traversal. E.g. a list component might use the arrow keys for internal navigation so it will switch this flag to true in order to prevent the focus manager from moving to the next component.

      Parameters
      • handlesInput: @param handlesInput indicates whether key events can be grabbed for focus traversal
    • hasFocus

      public boolean hasFocus()

      Returns true if the component has focus

      Returns

      true if the component has focus; otherwise false

      See also
      • #requestFocus
    • setFocus

      public void setFocus(boolean focused)

      This flag doesn't really give focus, its a state that determines what colors from the Style should be used when painting the component. Actual focus is determined by the parent form

      Parameters
      • focused: @param focused sets the state that determines what colors from the Style should be used when painting a focused component
      Deprecated

      this method shouldn't be invoked by user code, use requestFocus() instead

      See also
      • #requestFocus
    • getComponentForm

      public Form getComponentForm()

      Returns the Component Form or null if this Component is not added yet to a form

      Returns

      the Component Form

    • repaint

      public void repaint()

      Repaint this Component, the repaint call causes a callback of the paint method on the event dispatch thread.

      See also
      • Display
    • repaint

      public void repaint(int x, int y, int w, int h)

      Repaints a specific region within the component

      Parameters
      • x: boundary of the region to repaint in absolute screen coordinates not component coordinates

      • y: boundary of the region to repaint in absolute screen coordinates not component coordinates

      • w: boundary of the region to repaint

      • h: boundary of the region to repaint

    • longKeyPress

      protected void longKeyPress(int keyCode)

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

      Parameters
      • keyCode: the key code value to indicate a physical key.
    • keyPressed

      public void keyPressed(int keyCode)

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

      Parameters
      • keyCode: the key code value to indicate a physical key.
    • keyReleased

      public void keyReleased(int keyCode)

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

      Parameters
      • keyCode: the key code value to indicate a physical key.
    • keyRepeated

      public void keyRepeated(int keyCode)

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

      Parameters
      • keyCode: the key code value to indicate a physical key.
    • getAnimationManager

      public AnimationManager getAnimationManager()

      Returns the animation manager of the parent form or null if this component isn't currently associated with a form

      Returns

      the animation manager instance

    • getScrollAnimationSpeed

      public int getScrollAnimationSpeed()

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

      Returns

      scroll animation speed in milliseconds

    • setScrollAnimationSpeed

      public void setScrollAnimationSpeed(int animationSpeed)

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

      Parameters
      • animationSpeed: scroll animation speed in milliseconds
    • isBlockLead

      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

      Returns

      the blockLead

    • setBlockLead

      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

      Parameters
      • blockLead: the blockLead to set
    • isIgnorePointerEvents

      public boolean isIgnorePointerEvents()
      Returns

      the ignorePointerEvents

    • setIgnorePointerEvents

      public void setIgnorePointerEvents(boolean ignorePointerEvents)
      Parameters
      • ignorePointerEvents: the ignorePointerEvents to set
    • isRippleEffect

      public boolean isRippleEffect()

      Indicates whether the component displays the material design ripple effect

      Returns

      the rippleEffect

    • setRippleEffect

      public void setRippleEffect(boolean rippleEffect)

      Indicates whether the component displays the material design ripple effect

      Parameters
      • rippleEffect: the rippleEffect to set
    • getInlineStylesTheme

      public Resources getInlineStylesTheme()

      Gets the theme that is used by inline styles to reference images.

      Returns

      the inlineStylesTheme

      See also
      • #setInlineStylesTheme(com.codename1.ui.util.Resources)

      • #getInlineAllStyles()

      • #getInlineSelectedStyles()

      • #getInlinePressedStyles()

      • #getInlineUnselectedStyles()

      • #getInlineDisabledStyles()

    • setInlineStylesTheme

      public void setInlineStylesTheme(Resources inlineStylesTheme)

      Sets the theme that is used by inline styles to reference images. Inline styles will be disabled unless an inlineStylesTheme is registered with the component.

      Parameters
      • inlineStylesTheme: the theme that inline styles use to reference images.
      See also
      • #getInlineStylesTheme()

      • #setInlineAllStyles(java.lang.String)

      • #setInlinePressedStyles(java.lang.String)

      • #setInlineSelectedStyles(java.lang.String)

      • #setInlineDisabledStyles(java.lang.String)

      • #setInlineUnselectedStyles(java.lang.String)

    • shouldRenderComponentSelection

      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.

      Returns

      Defaults to false

    • isHideInLandscape

      public boolean isHideInLandscape()

      Indicates that this component and all its children should be hidden when the device is switched to landscape mode

      Returns

      the hideInLandscape

    • setHideInLandscape

      public void setHideInLandscape(boolean hideInLandscape)

      Indicates that this component and all its children should be hidden when the device is switched to landscape mode

      Parameters
      • hideInLandscape: 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
      • destUIID: the UIID to which this component will gradually shift

      • duration: the duration of the animation or the number of steps

      Returns

      an animation component that can either be stepped or played

    • isSmoothScrolling

      public boolean isSmoothScrolling()

      Indicates that scrolling through the component should work as an animation

      Returns

      whether this component use smooth scrolling

    • setSmoothScrolling

      public void setSmoothScrolling(boolean smoothScrolling)

      Indicates that scrolling through the component should work as an animation

      Parameters
      • smoothScrolling: indicates if a component uses smooth scrolling
    • pointerHover

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

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

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

    • pointerHoverReleased

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

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

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

    • pointerHoverPressed

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

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

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

    • pinch

      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

      Parameters
      • scale: @param scale 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

      false by default

    • pinchReleased

      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).

      Parameters
      • x: The x-coordinate of the remaining finger in the drag. (Absolute)

      • y: The y-coordinate of the remaining finger in the drag. (Absolute)

      Since

      7.0

    • pinch

      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

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

      Returns

      false by default, true if pinch is handled

    • isPinchBlocksDragAndDrop

      public boolean isPinchBlocksDragAndDrop()
      returns true if pinch will block drag and drop
    • setPinchBlocksDragAndDrop

      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). Setting setPinchBlocksDragAndDrop to true will prevent drag from triggering.

      Parameters
      • block: 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)

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

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

    • getDragImage

      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

      Returns

      an image

    • getDragTransparency

      public byte getDragTransparency()

      Returns the translucency used in the #getDragImage() method.

      Returns

      a number between 0 and 255 where 255 indicates an opaque image.

    • setDragTransparency

      public void setDragTransparency(byte dragTransparency)

      Sets the translucency of the #getDragImage() method.

      Parameters
      • dragTransparency: @param dragTransparency a number between 0 and 255 where 255 indicates an opaque image.
    • toImage

      public Image toImage()

      Returns the component as an image.

      Returns

      This component as an image.

    • dragInitiated

      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
    • drawDraggedImage

      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

      Parameters
      • g: the graphics context

      • img: the image

      • x: x position

      • y: y position

    • draggingOver

      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). This method can also update the drop tagets appearance to indicate the drop location.

      Parameters
      • dragged: the component being dragged

      • x: the x location over the component

      • y: the y location over the component

      Returns

      true if a drop at this location will be successful

    • dragEnter

      protected void dragEnter(Component dragged)

      This callback method indicates that a component drag has just entered this component

      Parameters
      • dragged: the component being dragged
    • dragExit

      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. E.g. if a component provides drop indication visuaization in draggingOver this visualization should be cleared..

      Parameters
      • dragged: the component being dragged
    • drop

      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 dragging a component and dropping it has no effect

      Parameters
      • dragged: the component being dropped

      • x: the x coordinate of the drop

      • y: 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
      • task: the refresh task to execute.
    • respondsToPointerEvents

      public boolean respondsToPointerEvents()

      Checks if the component responds to pointer events. A component is considered to respond to pointer events if it is visible and enabled, and is either scrollable, focusable, or has the #isGrabsPointerEvents() flag true.

      Returns

      True if the pointer responds to pointer events.

    • pointerDragged

      public void pointerDragged(int x, int y)

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

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

    • isStickyDrag

      protected boolean isStickyDrag()

      Returns true if the component is interested in receiving drag/pointer release events even after the gesture exceeded its boundaries. This is useful for spinners etc. where the motion might continue beyond the size of the component

      Returns

      false by default

    • pointerPressed

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

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

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

    • isDragAndDropOperation

      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"

      Parameters
      • x: the x coordinate relative to the component

      • y: the y coordinate relative to the component

      Returns

      true if a press in this point might indicate the desire to begin a drag operation

    • pointerPressed

      public void pointerPressed(int x, int y)

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

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

    • pointerReleased

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

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

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

    • longPointerPress

      public void longPointerPress(int x, int y)
      If this Component is focused this method is invoked when the user presses and holds the pointer on the Component
    • pointerReleased

      public void pointerReleased(int x, int y)

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

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

    • isTensileDragEnabled

      public boolean isTensileDragEnabled()

      Indicates whether tensile drag (dragging beyond the boundry of the component and snapping back) is enabled for this component.

      Returns

      true when tensile drag is enabled

    • setTensileDragEnabled

      public void setTensileDragEnabled(boolean tensileDragEnabled)

      Indicates whether tensile drag (dragging beyond the boundry of the component and snapping back) is enabled for this component.

      Parameters
      • tensileDragEnabled: true to enable tensile drag
    • getTextSelectionSupport

      public TextSelection.TextSelectionSupport getTextSelectionSupport()

      Returns text selection support object for this component. Only used by components that support text selection (e.g. Labels, un-editable text fields, etc..).

      Returns

      text selection support object

      Since

      7.0

    • addDropListener

      public void addDropListener(ActionListener l)

      Binds an action listener to drop events which are invoked when this component is dropped on a target

      Parameters
      • l: the callback
    • removeDropListener

      public void removeDropListener(ActionListener l)

      Removes an action listener to drop events which are invoked when this component is dropped on a target

      Parameters
      • l: the callback
    • addDragOverListener

      public void addDragOverListener(ActionListener l)

      Broadcasts an event when dragging over a component

      Parameters
      • l: the listener
    • removeDragOverListener

      public void removeDragOverListener(ActionListener l)

      Removes an action listener to drag over events

      Parameters
      • l: the callback
    • dragFinished

      protected void dragFinished(int x, int y)

      Callback indicating that the drag has finished either via drop or by releasing the component

      Parameters
      • x: the x location

      • y: the y location

    • addDragFinishedListener

      public void addDragFinishedListener(ActionListener l)

      Adds a listener to the dragFinished event

      Parameters
      • l: callback to receive drag finished events events
    • addStateChangeListener

      public void addStateChangeListener(ActionListener<ComponentStateChangeEvent> l)

      Adds a listener to be notified when the state of this component is changed to and from initialized.

      Parameters
      • l: Listener to be subscribed.
      Since

      7.0

    • removeStateChangeListener

      public void removeStateChangeListener(ActionListener<ComponentStateChangeEvent> l)

      Removes a listener from being notified when the state of this component is changed to and from initialized.

      Parameters
      • l: Listener to be unsubscribed.
      Since

      7.0

    • addPointerPressedListener

      public void addPointerPressedListener(ActionListener l)

      Adds a listener to the pointer event

      Parameters
      • l: callback to receive pointer events
    • addLongPressListener

      public void addLongPressListener(ActionListener l)

      Adds a listener to the pointer event

      Parameters
      • l: callback to receive pointer events
      Since

      7.0

    • paintRippleOverlay

      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. This method is invoked after paintBackground and is invoked repeatedly until the users finger is removed, it will only be invoked if isRippleEffect returns true

      Parameters
      • g: the graphics object for the component clipped to the background

      • x: the x position of the touch

      • y: the y position of the touch

      • position: @param position 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)

      Removes the listener from the pointer event

      Parameters
      • l: callback to remove
    • removeLongPressListener

      public void removeLongPressListener(ActionListener l)

      Removes the listener from the pointer event

      Parameters
      • l: callback to remove
      Since

      7.0

    • removeDragFinishedListener

      public void removeDragFinishedListener(ActionListener l)

      Removes the listener from the drag finished event

      Parameters
      • l: callback to remove
    • addPointerReleasedListener

      public void addPointerReleasedListener(ActionListener l)

      Adds a listener to the pointer event

      Parameters
      • l: callback to receive pointer events
    • removePointerReleasedListener

      public void removePointerReleasedListener(ActionListener l)

      Removes the listener from the pointer event

      Parameters
      • l: callback to remove
    • addPointerDraggedListener

      public void addPointerDraggedListener(ActionListener l)

      Adds a listener to the pointer event

      Parameters
      • l: callback to receive pointer events
    • removePointerDraggedListener

      public void removePointerDraggedListener(ActionListener l)

      Removes the listener from the pointer event

      Parameters
      • l: callback to remove
    • getDragSpeed

      protected float getDragSpeed(boolean vertical)

      This method returns the dragging speed based on the latest dragged events

      Parameters
      • vertical: indicates what axis speed is required
      Returns

      the dragging speed

    • getStyle

      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.

      Returns

      the component Style object

    • getPressedStyle

      public Style getPressedStyle()

      Returns the Component Style for the pressed state allowing us to manipulate the look of the component when it is pressed

      Returns

      the component Style object

    • setPressedStyle

      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

      Parameters
      • style: the component Style object
    • initUnselectedStyle

      protected void initUnselectedStyle(Style unselectedStyle)

      Can be overridden by subclasses to perform initialization when the unselected style is set to a new value.

      Parameters
      • unselectedStyle: The unselected style.
      Since

      8.0

    • initPressedStyle

      protected void initPressedStyle(Style pressedStyle)

      Can be overridden by subclasses to perform initialization when the pressed style is set to a new value.

      Parameters
      • unselectedStyle: The pressed style.
      Since

      8.0

    • initDisabledStyle

      protected void initDisabledStyle(Style disabledStyle)

      Can be overridden by subclasses to perform initialization when the disabled style is set to a new value.

      Parameters
      • unselectedStyle: The disabled style.
      Since

      8.0

    • initSelectedStyle

      protected void initSelectedStyle(Style selectedStyle)

      Can be overridden by subclasses to perform initialization when the selected style is set to a new value.

      Parameters
      • unselectedStyle: The selected style.
      Since

      8.0

    • getUnselectedStyle

      public final Style getUnselectedStyle()

      Returns the Component Style for the unselected mode allowing us to manipulate the look of the component

      Returns

      the component Style object

    • setUnselectedStyle

      public void setUnselectedStyle(Style style)

      Changes the Component Style by replacing the Component Style with the given Style

      Parameters
      • style: the component Style object
    • getSelectedStyle

      public Style getSelectedStyle()

      Returns the Component Style for the selected state allowing us to manipulate the look of the component when it owns focus

      Returns

      the component Style object

    • setSelectedStyle

      public void setSelectedStyle(Style style)

      Changes the Component selected Style by replacing the Component Style with the given Style

      Parameters
      • style: the component Style object
    • getDisabledStyle

      public Style getDisabledStyle()

      Returns the Component Style for the disabled state allowing us to manipulate the look of the component when its disabled

      Returns

      the component Style object

    • setDisabledStyle

      public void setDisabledStyle(Style style)

      Changes the Component disalbed Style by replacing the Component Style with the given Style

      Parameters
      • style: the component Style object
    • installDefaultPainter

      protected void installDefaultPainter(Style s)

      Allows subclasses to create their own custom style types and install the background painter into them

      Parameters
      • s: the custom style
    • requestFocus

      public void requestFocus()
      Changes the current component to the focused component, will work only for a component that belongs to a parent form.
    • toString

      public String toString()

      Overriden to return a useful value for debugging purposes

      Returns

      a string representation of this component

      Overrides:
      toString in class Object
    • paramString

      protected String paramString()

      Returns a string representing the state of this component. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

      Returns

      a string representation of this component's state

    • refreshTheme

      public void refreshTheme()
      Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!
    • refreshTheme

      public void refreshTheme(boolean merge)

      Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!

      Parameters
      • merge: indicates if the current styles should be merged with the new styles
    • refreshTheme

      protected void refreshTheme(String id, boolean merge)

      Makes sure the component is up to date with the given UIID

      Parameters
      • id: The Style Id to update the Component with

      • merge: indicates if the current styles should be merged with the new styles

    • isDragActivated

      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.

      Returns

      true if we are in the middle of a drag; otherwise false

    • getGridPosY

      protected int getGridPosY()

      This method should be implemented correctly by subclasses to make snap to grid functionality work as expected. Returns the ideal grid Y position closest to the current Y position.

      Returns

      a valid Y position in the grid

    • getGridPosX

      protected int getGridPosX()

      This method should be implemented correctly by subclasses to make snap to grid functionality work as expected. Returns the ideal grid X position closest to the current X position.

      Returns

      a valid Y position in the grid

    • animate

      public boolean animate()

      Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the com.codename1.ui.Display class.

      Returns

      true if a repaint is desired or false if no repaint is necessary

      Specified by:
      animate in interface Animation
    • scrollRectToVisible

      protected void scrollRectToVisible(Rectangle rect, Component coordinateSpace)

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

      Parameters
      • rect: the rectangle that need to be visible

      • coordinateSpace: @param coordinateSpace 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)

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

      Parameters
      • x

      • y

      • width

      • height

      • coordinateSpace: @param coordinateSpace 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)

      Draws the component border if such a border exists. The border unlike the content of the component will not be affected by scrolling for a scrollable component.

      Parameters
      • g: graphics context on which the border is painted
    • paintBorderBackground

      protected void paintBorderBackground(Graphics g)

      Draws the component border background if such a border exists.

      Parameters
      • g: graphics context on which the border is painted
    • isCellRenderer

      public boolean isCellRenderer()

      Used as an optimization to mark that this component is currently being used as a cell renderer

      Returns

      true is this component is currently being used as a cell renderer

    • setCellRenderer

      public void setCellRenderer(boolean cellRenderer)

      Used as an optimization to mark that this component is currently being used as a cell renderer

      Parameters
      • cellRenderer: @param cellRenderer indicate whether this component is currently being used as a cell renderer
    • isScrollVisible

      public boolean isScrollVisible()

      Indicate whether this component scroll is visible

      Returns

      true is this component scroll is visible; otherwise false

    • setScrollVisible

      public void setScrollVisible(boolean isScrollVisible)

      Set whether this component scroll is visible

      Parameters
      • isScrollVisible: Indicate whether this component scroll is visible
    • setIsScrollVisible

      public void setIsScrollVisible(boolean isScrollVisible)

      Set whether this component scroll is visible

      Parameters
      • isScrollVisible: Indicate whether this component scroll is visible
      Deprecated

      replaced by setScrollVisible to match the JavaBeans spec

    • startEditingAsync

      public void startEditingAsync()

      If the component #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.

      See also
      • #stopEditing(java.lang.Runnable)

      • #isEditing()

      • #isEditable()

      • #getEditingDelegate()

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

      Specified by:
      startEditingAsync in interface Editable
    • stopEditing

      public void stopEditing(Runnable onFinish)

      Stops the editing process.

      Parameters
      • onFinish: Callback called when the editing is complete.
      See also
      • #startEditingAsync()

      • #isEditing()

      • #isEditable()

      • #getEditingDelegate()

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

      Specified by:
      stopEditing in interface Editable
    • isEditing

      public boolean isEditing()

      Checks if the component is currently being edited.

      Returns

      True if the component is currently being edited.

      See also
      • #startEditingAsync()

      • #stopEditing(java.lang.Runnable)

      • #isEditable()

      • #getEditingDelegate()

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

      Specified by:
      isEditing in interface Editable
    • isEditable

      public boolean isEditable()

      Checks to see if the component is editable. This is used for next/previous focus traversal on forms.

      See also
      • #getEditingDelegate()

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

      • #isEditing()

      • #startEditingAsync()

      • #stopEditing(java.lang.Runnable)

      Specified by:
      isEditable in interface Editable
    • laidOut

      protected void laidOut()
      This is a callback method to inform the Component when it's been laidout on the parent Container
    • deinitialize

      protected void deinitialize()
      Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.
    • initComponent

      protected void initComponent()
      Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
    • isInitialized

      protected boolean isInitialized()

      Indicates if the component is in the initialized state, a component is initialized when its initComponent() method was invoked. The initMethod is invoked before showing the component to the user.

      Returns

      true if the component is in the initialized state

    • setInitialized

      protected void setInitialized(boolean initialized)

      Indicates if the component is in the initialized state, a component is initialized when its initComponent() method was invoked. The initMethod is invoked before showing the component to the user.

      Parameters
      • initialized: 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
      • propertyName: the property name that was changed

      • source: The changed Style object

      Specified by:
      styleChanged in interface StyleListener
    • getNextFocusDown

      public Component getNextFocusDown()

      Allows us to determine which component will receive focus next when traversing with the down key

      Returns

      the next focus component

    • setNextFocusDown

      public void setNextFocusDown(Component nextFocusDown)

      Allows us to determine which component will receive focus next when traversing with the down key

      Parameters
      • nextFocusDown: the next focus component
    • getNextFocusUp

      public Component getNextFocusUp()

      Allows us to determine which component will receive focus next when traversing with the up key.

      Returns

      the nxt focus component

    • setNextFocusUp

      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.

      Parameters
      • nextFocusUp: next focus component
    • getNextFocusLeft

      public Component getNextFocusLeft()

      Allows us to determine which component will receive focus next when traversing with the left key.

      Returns

      the next focus component

    • setNextFocusLeft

      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.

      Parameters
      • nextFocusLeft: the next focus component
    • getNextFocusRight

      public Component getNextFocusRight()

      Allows us to determine which component will receive focus next when traversing with the right key

      Returns

      the next focus component

    • setNextFocusRight

      public void setNextFocusRight(Component nextFocusRight)

      Allows us to determine which component will receive focus next when traversing with the right key

      Parameters
      • nextFocusRight: the next focus component
    • isEnabled

      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

      Returns

      true if enabled

    • setEnabled

      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

      Parameters
      • enabled: true to enable false to disable
    • getName

      public String getName()

      A component name allows us to easily identify the component within a dynamic UI.

      Returns

      name of the component

    • setName

      public void setName(String name)

      A component name allows us to easily identify the component within a dynamic UI.

      Parameters
      • name: a name for the component
    • initCustomStyle

      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

      Parameters
      • s: style to initialize
    • deinitializeCustomStyle

      protected void deinitializeCustomStyle(Style s)

      Allows components to create a style of their own, this method cleans up state for the given style

      Parameters
      • s: style no longer used
    • isRTL

      public final boolean isRTL()

      Is the component a bidi RTL component

      Returns

      true if the component is working in a right to left mode

    • setRTL

      public void setRTL(boolean rtl)

      Is the component a bidi RTL component

      Parameters
      • rtl: true if the component should work in a right to left mode
    • isTactileTouch

      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

      Parameters
      • x: the x position

      • y: the y position

      Returns

      True if the device should vibrate

    • isTactileTouch

      public boolean isTactileTouch()

      Indicates whether the component should "trigger" tactile touch when pressed by the user in a touch screen UI.

      Returns

      the tactileTouch

    • setTactileTouch

      public void setTactileTouch(boolean tactileTouch)

      Indicates whether the component should "trigger" tactile touch when pressed by the user in a touch screen UI.

      Parameters
      • tactileTouch: true to trigger vibration when the component is pressed
    • getPropertyNames

      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

      Returns

      the property names allowing mutation

    • getPropertyTypes

      public Class[] getPropertyTypes()

      Matches the property names method (see that method for further details).

      Returns

      the types of the properties

    • getPropertyTypeNames

      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[],Image,Image[],Object[],ListModel,ListCellRenderer

      Returns

      Array of type names

    • getPropertyValue

      public Object getPropertyValue(String name)

      Returns the current value of the property name, this method is used by the GUI builder

      Parameters
      • name: the name of the property
      Returns

      the value of said property

    • setPropertyValue

      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. Notice that some builtin properties such as "$designMode" might be sent to components to indicate application state.

      Parameters
      • name: the name of the property

      • value: new value for the property

      Returns

      error message or null

    • paintLockRelease

      public void paintLockRelease()
      Releases the paint lock image to allow paint to work as usual, see paintLock(boolean) for details
    • 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
      • hardLock: indicates whether the lock uses a hard or a soft reference to the image
      Returns

      the image in case of a hard lock

    • isSnapToGrid

      public boolean isSnapToGrid()

      Indicates whether scrolling this component should jump to a specific location in a grid

      Returns

      the snapToGrid

    • setSnapToGrid

      public void setSnapToGrid(boolean snapToGrid)

      Indicates whether scrolling this component should jump to a specific location in a grid

      Parameters
      • snapToGrid: the snapToGrid to set
      Deprecated
    • shouldBlockSideSwipe

      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.
    • shouldBlockSideSwipeLeft

      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.
    • shouldBlockSideSwipeRight

      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.
    • 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().

      Since

      7.0

    • isFlatten

      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. This does have a significant memory overhead.

      Returns

      the flatten property

    • setFlatten

      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. This does have a significant memory overhead.

      Parameters
      • flatten: the flatten value
    • getTensileLength

      public int getTensileLength()

      Recommended length for the tensile, -1 for default

      Returns

      Recommended length for the tensile, -1 for default

    • setTensileLength

      public void setTensileLength(int tensileLength)

      Recommended length for the tensile, -1 for default

      Parameters
      • tensileLength: length for tensile drag
    • isGrabsPointerEvents

      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.

      Returns

      the grabsPointerEvents

    • setGrabsPointerEvents

      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.

      Parameters
      • grabsPointerEvents: the grabsPointerEvents to set
    • getScrollOpacityChangeSpeed

      public int getScrollOpacityChangeSpeed()

      Indicates the decrement units for the scroll opacity

      Returns

      the scrollOpacityChangeSpeed

    • setScrollOpacityChangeSpeed

      public void setScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed)

      Indicates the decrement units for the scroll opacity

      Parameters
      • scrollOpacityChangeSpeed: the scrollOpacityChangeSpeed to set
    • growShrink

      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. Notice that some components (such as text areas) don't report proper preferred size untill they are laid out once. Hence the first time around a text area (or container containing a text area) will not produce the expected effect. This can be solved by invoking revalidate before the call to this method only the first time around!

      Parameters
      • duration: the duration in milliseconds for the grow/shrink animation
    • isAlwaysTensile

      public boolean isAlwaysTensile()

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

      Returns

      the alwaysTensile

    • setAlwaysTensile

      public void setAlwaysTensile(boolean alwaysTensile)

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

      Parameters
      • alwaysTensile: the alwaysTensile to set
    • isDraggable

      public boolean isDraggable()

      Indicates whether this component can be dragged in a drag and drop operation rather than scroll the parent

      Returns

      the draggable state

    • setDraggable

      public void setDraggable(boolean draggable)

      Indicates whether this component can be dragged in a drag and drop operation rather than scroll the parent

      Parameters
      • draggable: the draggable to set
    • isDropTarget

      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

      Returns

      the dropTarget state

    • setDropTarget

      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

      Parameters
      • dropTarget: the dropTarget to set
    • isChildOf

      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

      Parameters
      • cnt: a potential parent of this component
      Returns

      false if the container isn't one of our parent containers

    • isHideInPortrait

      public boolean isHideInPortrait()

      Indicates that this component and all its children should be hidden when the device is switched to portrait mode

      Returns

      the hideInPortrait

    • setHideInPortrait

      public void setHideInPortrait(boolean hideInPortrait)

      Indicates that this component and all its children should be hidden when the device is switched to portrait mode

      Parameters
      • hideInPortrait: set to true in order to hide when in portrait
    • cancelRepaints

      protected void cancelRepaints()
      remove this component from the painting queue
    • getBindablePropertyNames

      public String[] getBindablePropertyNames()

      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

      Returns

      a string array of property names or null

      Deprecated

      this mapped to an older iteration of properties that is no longer used

    • getBindablePropertyTypes

      public Class[] getBindablePropertyTypes()

      Returns the types of the properties that are bindable within this component

      Returns

      the class for binding

      Deprecated

      this mapped to an older iteration of properties that is no longer used

    • bindProperty

      public void bindProperty(String prop, BindTarget target)

      Binds the given property name to the given bind target

      Parameters
      • prop: the property name

      • target: the target binder

      Deprecated

      this mapped to an older iteration of properties that is no longer used

    • unbindProperty

      public void unbindProperty(String prop, BindTarget target)

      Removes a bind target from the given property name

      Parameters
      • prop: the property names

      • target: the target binder

      Deprecated

      this mapped to an older iteration of properties that is no longer used

    • getBoundPropertyValue

      public Object getBoundPropertyValue(String prop)

      Allows the binding code to extract the value of the property

      Parameters
      • prop: the property
      Returns

      the value for the property

      Deprecated

      this mapped to an older iteration of properties that is no longer used

    • setBoundPropertyValue

      public void setBoundPropertyValue(String prop, Object value)

      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!

      Parameters
      • prop: the property whose value should be set

      • value: the value

      Deprecated

      this mapped to an older iteration of properties that is no longer used

    • getCloudBoundProperty

      public String getCloudBoundProperty()

      Indicates the property within this component that should be bound to the cloud object

      Returns

      the cloudBoundProperty

      Deprecated

      this mapped to an older iteration of properties that is no longer used

    • setCloudBoundProperty

      public void setCloudBoundProperty(String cloudBoundProperty)

      Indicates the property within this component that should be bound to the cloud object

      Parameters
      • cloudBoundProperty: the cloudBoundProperty to set
      Deprecated

      this mapped to an older iteration of properties that is no longer used

    • getCloudDestinationProperty

      public String getCloudDestinationProperty()

      The destination property of the CloudObject

      Returns

      the cloudDestinationProperty

      Deprecated

      this mapped to an older iteration of properties that is no longer used

    • setCloudDestinationProperty

      public void setCloudDestinationProperty(String cloudDestinationProperty)

      The destination property of the CloudObject

      Parameters
      • cloudDestinationProperty: the cloudDestinationProperty to set
      Deprecated

      this mapped to an older iteration of properties that is no longer used

    • getComponentState

      public Object getComponentState()

      Some components may optionally generate a state which can then be restored using setCompnentState(). This method is used by the UIBuilder.

      Returns

      the component state or null for undefined state.

    • setComponentState

      public void setComponentState(Object state)

      If getComponentState returned a value the setter can update the value and restore the prior state.

      Parameters
      • state: the non-null state
    • setHidden

      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. This method also optionally sets the margin to 0 so the component will be truly hidden. Notice that this might not behave as expected with scrollable containers or layouts that ignore preferred size.

      Parameters
      • b: true to hide the component and false to show it

      • changeMargin: indicates margin should be set to 0

    • isHidden

      public boolean isHidden()

      Returns true if the component was explicitly hidden by the user. This method doesn't check if the parent component is hidden, so it is possible that the component would be hidden from the UI, but that this would still return true. Use #isHidden(boolean) with true to check also if the parent is hidden.

      Returns

      true if the component is hidden, notice that the hidden property and visible property have different meanings in the API!

    • setHidden

      public void setHidden(boolean b)

      Makes the components preferred size equal 0 when hidden and restores it to the default size when not. Also toggles the UIID to "Container" and back to allow padding/margin to be removed. Since the visible flag just hides the component without "removing" the space it occupies this is the flag that can be used to truly hide a component within the UI. Notice that this might not behave as expected with scrollable containers or layouts that ignore preferred size.

      Parameters
      • b: true to hide the component and false to show it
    • isHidden

      public boolean isHidden(boolean checkParent)

      Checks if the component is hidden. If checkParent is true, this also checks to see if the parent is hidden, and will return true if either this component is hidden, or the parent is hidden.

      Parameters
      • checkParent: True to check if parent is hidden also.
      Returns

      Returns true if the component is hidden.

      Since

      7.0

    • announceForAccessibility

      public void announceForAccessibility(String text)

      Manually announces text to native accessibility services, associating the announcement with this component when possible. Screen readers normally announce a component automatically when it gains focus; this helper is for additional announcements that should occur outside of focus changes.

      Parameters
      • text: the message to announce
    • getAccessibilityText

      public String getAccessibilityText()

      Returns the text that describes this component to assistive technologies. If no text was set explicitly, this method attempts to derive a description from the component's label or content.

      Returns

      accessibility description or null if none

    • setAccessibilityText

      public void setAccessibilityText(String text)

      Sets the text that describes this component to assistive technologies. When the component gains focus, this text will be announced automatically.

      Parameters
      • text: accessibility description
    • getTooltip

      public String getTooltip()
      Returns

      the tooltip

    • setTooltip

      public void setTooltip(String tooltip)
      Parameters
      • tooltip: the tooltip to set