Class Component
- All Implemented Interfaces:
Animation, Editable, StyleListener
- Direct Known Subclasses:
ChartComponent, CommonProgressAnimations.ProgressAnimation, Container, ImageViewer, InfiniteProgress, Label, List, PeerComponent, Switch, TextArea
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
FieldsModifier and TypeFieldDescriptionstatic final intAlignment to the baseline constraintstatic final intBox-orientation constant used to specify the bottom of a box.static final intBaseline resize behavior constant used to properly align components.static final intBaseline resize behavior constant used to properly align components.static final intBaseline resize behavior constant used to properly align components.static final intBaseline resize behavior constant used to properly align components.static final intIndicates a Component center alignmentstatic final intThe crosshair cursor type.static final intThe default cursorstatic final intUsed by getDragRegionStatus to indicate immediate dragabilitystatic final intUsed by getDragRegionStatus to indicate immediate dragabilitystatic final intUsed by getDragRegionStatus to indicate immediate dragabilitystatic final intUsed by getDragRegionStatus to indicate likely dragabilitystatic final intUsed by getDragRegionStatus to indicate likely dragabilitystatic final intUsed by getDragRegionStatus to indicate likely dragabilitystatic final intUsed by getDragRegionStatus to indicate no dragabilitystatic final intUsed by getDragRegionStatus to indicate limited dragabilitystatic final intUsed by getDragRegionStatus to indicate limited dragabilitystatic final intUsed by getDragRegionStatus to indicate limited dragabilitystatic final intThe east-resize cursor type.static final intThe hand cursor type.static final intBox-orientation constant used to specify the left side of a box.static final intThe move cursor type.static final intThe north-resize cursor type.static final intThe north-east-resize cursor type.static final intThe north-west-resize cursor type.static final intBox-orientation constant used to specify the right side of a box.static final intThe south-resize cursor type.static final intThe south-east-resize cursor type.static final intThe south-west-resize cursor type.static final intThe text cursor type.static final intBox-orientation constant used to specify the top of a box.static final intThe west-resize cursor type.static final intThe wait cursor type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener to the dragFinished eventvoidBroadcasts an event when dragging over a componentvoidBinds an action listener to drop events which are invoked when this component is dropped on a targetvoidRegisters interest in receiving callbacks for focus gained events, a focus event is invoked when the component accepts the focus.voidAdds a listener to the pointer eventvoidAdds a listener to the pointer eventvoidAdds a listener to the pointer eventvoidAdds a listener to the pointer eventvoidaddPullToRefresh(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.voidRegisters interest in receiving callbacks for scroll gained events, a scroll event is invoked when the component is scrolled.voidAdds a listener to be notified when the state of this component is changed to and from initialized.booleananimate()Allows the animation to reduce "repaint" calls when it returns false.voidManually announces text to native accessibility services, associating the announcement with this component when possible.voidbindProperty(String prop, BindTarget target) Binds the given property name to the given bind targetfinal booleanA 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 DimensionCalculates the preferred size based on component content.protected DimensionMethod that can be overriden to represent the actual size of the component when it differs from the desireable size for the viewportprotected voidremove this component from the painting queuevoidClears all client properties from this Componentbooleancontains(int x, int y) Returns true if the given absolute coordinate is contained in the ComponentbooleancontainsOrOwns(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 voidInvoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.protected voidAllows components to create a style of their own, this method cleans up state for the given styleprotected voidThis callback method indicates that a component drag has just entered this componentprotected voidThis 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 voiddragFinished(int x, int y) Callback indicating that the drag has finished either via drop or by releasing the componentprotected booleandraggingOver(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 voidInvoked 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 scrollingprotected voiddrawDraggedImage(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 indicationvoidPerforms 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 effectprotected voidWhen 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 voidCallback allowing a developer to track when the component gains focusprotected voidCallback allowing a developer to track wheh the component loses focusintReturns 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()intReturns 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 StyleReturns 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 formintgetBaseline(int width, int height) The baseline for the component text according to which it should be aligned with other components for best visual look.intReturns a constant indicating how the baseline varies with the size of the component.String[]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 boundClass[]Returns the types of the properties that are bindable within this componentprotected BorderNormally returns getStyle().getBorder() but some subclasses might use this to programmatically replace the border in runtime e.g.intReturns the gap to be left for the bottom scrollbar on the X axis.getBoundPropertyValue(String prop) Allows the binding code to extract the value of the propertyprotected RectangleReturns the component bounds which is sometimes more convenient than invoking getX/Y/Width/Height.Returns the bounds of this component in the provided Rectangle.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.Indicates the property within this component that should be bound to the cloud objectThe destination property of the CloudObjectReturns the Component Form or null if this Component is not added yet to a formSome components may optionally generate a state which can then be restored using setCompnentState().intGets the custom cursor for this component.static byteReturns the default translucency used in the#getDragImage()method.final Rectanglegets 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 disabledintGets the current dragged x values when the Component is being draggedintGets the current dragged y values when the Component is being draggedprotected ImageThis 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 operationprotected intgetDragRegionStatus(int x, int y) Indicates if the section within the X/Y area is a "drag region" where we expect people to drag or press in which case we can instantly start dragging making perceived performance faster.protected floatgetDragSpeed(boolean vertical) This method returns the dragging speed based on the latest dragged eventsbyteReturns the translucency used in the#getDragImage()method.Gets the delegate that handles the editing of this component.protected intThis method should be implemented correctly by subclasses to make snap to grid functionality work as expected.protected intThis method should be implemented correctly by subclasses to make snap to grid functionality work as expected.intReturns the component heightGets 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.intGets the inner height of this component.intGets the preferred height removing vertical padding.intGets the preferred width removing horizontal padding.intGets the inner width of this component.intGets x-coordinate of the inner bounds of this component.intGets 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.getName()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 keyAllows 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 keyAllows us to determine which component will receive focus next when traversing with the up key.intGets the outer height of this component.intGets the preferred height including the vertical margins.intGets the preferred width including horizontal margins.intGets the outer width of this component.intGets the x-coordinate of the outer bounds of this component.intGets the Y-coordinate of the outer bounds of this component.getOwner()Gets the "owner" of this component as set by#setOwner(com.codename1.ui.Component).Returns the container in which this component is containedintHelper 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.intGets the preferred tab index of this component.intHelper 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 pressedString[]A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder codeString[]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,ListCellRendererClass[]Matches the property names method (see that method for further details).getPropertyValue(String name) Returns the current value of the property name, this method is used by the GUI builderReturns the array of components that have an equal heightReturns the array of components that have an equal widthReturns the scrollable parent of this componentintScroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation modeReturns the Components dimension in scrolling, this is very similar to the preferred size aspect only it represents actual scrolling limits.intThis method is used internally by the look and feel to implement the fading scrollbar behavior.intIndicates the decrement units for the scroll opacityintIndicates 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.intIndicates 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 externallyReturns the Component Style for the selected state allowing us to manipulate the look of the component when it owns focusintReturns the gap to be left for the side scrollbar on the Y axis.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.intGets the tab index of the component.intRecommended length for the tensile, -1 for defaultReturns text selection support object for this component.Returns
final StringgetUIID()Unique identifier for a component.This method should be used by the Component to retrieve the correct UIManager to work withfinal StyleReturns the Component Style for the unselected mode allowing us to manipulate the look of the componentprotected RectangleReturns the component bounds for scrolling which might differ from the getBounds for large components e.g.getVisibleBounds(Rectangle rect) Returns the component bounds for scrolling which might differ from the getBounds for large components into the provided rectangle.intgetWidth()Returns the component widthintgetX()Returns the current component x location relatively to its parent containerintgetY()Returns the component y location relatively to its parent containervoidgrowShrink(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.booleanPrevents key events from being grabbed for focus traversal.booleanChecks 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.booleanhasFocus()Returns true if the component has focusprotected voidHides the native overlay for this component.protected voidAllows subclasses to bind functionality that relies on fully initialized and "ready for action" component stateprotected voidAllows components to create a style of their own, this method binds the listener to the style and installs a bg painterprotected voidinitDisabledStyle(Style disabledStyle) Can be overridden by subclasses to perform initialization when the disabled style is set to a new value.protected voidThis method initializes the Component defaults constantsprotected voidinitPressedStyle(Style pressedStyle) Can be overridden by subclasses to perform initialization when the pressed style is set to a new value.protected voidinitSelectedStyle(Style selectedStyle) Can be overridden by subclasses to perform initialization when the selected style is set to a new value.protected voidinitUnselectedStyle(Style unselectedStyle) Can be overridden by subclasses to perform initialization when the unselected style is set to a new value.protected voidAllows subclasses to create their own custom style types and install the background painter into thembooleanEnable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)booleanPrevent a lead component hierarchy from this specific component, this allows a component within that hierarchy to still act as a standalone componentbooleanUsed as an optimization to mark that this component is currently being used as a cell rendererbooleanSearches the hierarchy of the component recursively to see if the given Container is one of the parents of this componentprotected booleanIndicates 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 booleanisDragAndDropOperation(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"booleanIndicates whether this component can be dragged in a drag and drop operation rather than scroll the parentprotected booleanisDragRegion(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.booleanIndicates 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 targetbooleanChecks to see if the component is editable.booleanChecks if the component is currently being edited.booleanIndicates whether component is enabled or disabled thus allowing us to prevent a component from receiving input events and indicate so visuallybooleanMakes 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.booleanReturns true if this component can receive focus and is enabledbooleanThis 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.booleanisHidden()Returns true if the component was explicitly hidden by the user.booleanisHidden(boolean checkParent) Checks if the component is hidden.booleanIndicates that this component and all its children should be hidden when the device is switched to landscape modebooleanIndicates that this component and all its children should be hidden when the device is switched to portrait modebooleanReturns
protected booleanprotected booleanIndicates if the component is in the initialized state, a component is initialized when its initComponent() method was invoked.booleanisOpaque()Checks whether the component's background should be painted.booleanChecks to see if this component is owned by the given other component.booleanreturns true if pinch will block drag and dropbooleanIndicates whether the component displays the material design ripple effectfinal booleanisRTL()Is the component a bidi RTL componentprotected booleanIndicates whether the component should/could scroll by default a component is not scrollable.booleanIndicates whether the component should/could scroll on the X axisbooleanIndicates whether the component should/could scroll on the Y axisbooleanIndicate whether this component scroll is visibleprotected booleanThis 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 booleanChecks to see if this platform supports cursors.booleanIndicates that scrolling through the component should work as an animationbooleanIndicates whether scrolling this component should jump to a specific location in a gridprotected booleanReturns true if the component is interested in receiving drag/pointer release events even after the gesture exceeded its boundaries.booleanIndicates whether the component should "trigger" tactile touch when pressed by the user in a touch screen UI.protected booleanisTactileTouch(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 isTactileTouchbooleanIndicates whether tensile drag (dragging beyond the boundry of the component and snapping back) is enabled for this component.final booleanChecks if this component should be traversable using the keyboard using tab, next, previous keys.booleanReturns whether the component is visible or notvoidkeyPressed(int keyCode) If this Component is focused, the key pressed event will call this methodvoidkeyReleased(int keyCode) If this Component is focused, the key released event will call this methodvoidkeyRepeated(int keyCode) If this Component is focused, the key repeat event will call this method.protected voidlaidOut()This is a callback method to inform the Component when it's been laidout on the parent Containerprotected voidlongKeyPress(int keyCode) If this Component is focused this method is invoked when the user presses and holds the keyvoidlongPointerPress(int x, int y) If this Component is focused this method is invoked when the user presses and holds the pointer on the Componentprotected voidonScrollX(int scrollX) This method can be overriden to receive scroll events, unlike overriding setScrollX it will receive all calls for scrolling.protected voidonScrollY(int scrollY) This method can be overriden to receive scroll events, unlike overriding setScrollY it will receive all calls for scrolling.protected voidonSetFocusable(boolean focusable) Since setFocusable is final this callback is invoked when focusable changes.voidThis method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.protected voidThis method paints the Component background, it should be overriden by subclasses to perform custom background drawing.voidThis method paints all the parents Components Background.protected voidDraws the component border if such a border exists.protected voidDraws the component border background if such a border exists.final voidPaints this component as a root by going to all the parent components and setting the absolute translation based on coordinates and scroll status.final voidpaintComponent(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.voidPaints 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.voidReleases the paint lock image to allow paint to work as usual, see paintLock(boolean) for detailsvoidpaintRippleOverlay(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 voidPaints the UI for the scrollbars on the component, this will be invoked only for scrollable components.protected voidPaints the UI for the scrollbar on the X axis, this method allows component subclasses to customize the look of a scrollbarprotected voidPaints the UI for the scrollbar on the Y axis, this method allows component subclasses to customize the look of a scrollbarvoidpaintShadows(Graphics g, int relativeX, int relativeY) Paints the drop-shadow projections for this component based on its elevation value.protected StringReturns a string representing the state of this component.static DimensionparsePreferredSize(String preferredSize, Dimension baseSize) Parses the preferred size given as a stringprotected booleanpinch(float scale) Invoked by subclasses interested in handling pinch to zoom events, if true is returned other drag events will not be broadcastprotected booleanpinch(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 broadcastprotected voidpinchReleased(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).voidpointerDragged(int[] x, int[] y) If this Component is focused, the pointer dragged event will call this methodvoidpointerDragged(int x, int y) If this Component is focused, the pointer dragged event will call this methodvoidpointerHover(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerHoverPressed(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerHoverReleased(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerPressed(int[] x, int[] y) If this Component is focused, the pointer pressed event will call this methodvoidpointerPressed(int x, int y) If this Component is focused, the pointer pressed event will call this methodvoidpointerReleased(int[] x, int[] y) If this Component is focused, the pointer released event will call this methodvoidpointerReleased(int x, int y) If this Component is focused, the pointer released event will call this methodvoidputClientProperty(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.voidMakes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!voidrefreshTheme(boolean merge) Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!protected voidrefreshTheme(String id, boolean merge) Makes sure the component is up to date with the given UIIDvoidremove()This method will remove the Component from its parent.voidRemoves the listener from the drag finished eventvoidRemoves an action listener to drag over eventsvoidRemoves an action listener to drop events which are invoked when this component is dropped on a targetvoidDeregisters interest in receiving callbacks for focus gained eventsvoidRemoves the listener from the pointer eventvoidRemoves the listener from the pointer eventvoidRemoves the listener from the pointer eventvoidRemoves the listener from the pointer eventvoidDeregisters interest in receiving callbacks for scroll gained eventsvoidRemoves a listener from being notified when the state of this component is changed to and from initialized.voidrepaint()Repaint this Component, the repaint call causes a callback of the paint method on the event dispatch thread.voidrepaint(int x, int y, int w, int h) Repaints a specific region within the componentvoidChanges the current component to the focused component, will work only for a component that belongs to a parent form.protected voidRestores the state of the focusable flag to its default statebooleanChecks if the component responds to pointer events.voidscrollRectToVisible(int x, int y, int width, int height, Component coordinateSpace) Makes sure the component is visible in the scroll if this container is scrollableprotected voidscrollRectToVisible(Rectangle rect, Component coordinateSpace) Makes sure the component is visible in the scroll if this container is scrollablevoidsetAccessibilityText(String text) Sets the text that describes this component to assistive technologies.voidsetAlwaysTensile(boolean alwaysTensile) Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)voidsetBlockLead(boolean blockLead) Prevent a lead component hierarchy from this specific component, this allows a component within that hierarchy to still act as a standalone componentvoidsetBoundPropertyValue(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!voidsetCellRenderer(boolean cellRenderer) Used as an optimization to mark that this component is currently being used as a cell renderervoidsetCloudBoundProperty(String cloudBoundProperty) Indicates the property within this component that should be bound to the cloud objectvoidsetCloudDestinationProperty(String cloudDestinationProperty) The destination property of the CloudObjectvoidsetComponentState(Object state) If getComponentState returned a value the setter can update the value and restore the prior state.voidsetCursor(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 voidsetDefaultDragTransparency(byte defaultDragTransparency) Sets the default translucency of the#getDragImage()method.final voidsetDirtyRegion(Rectangle dirty) sets the Component dirty region, this method is for internal use only and SHOULD NOT be invoked by user code.voidsetDisabledStyle(Style style) Changes the Component disalbed Style by replacing the Component Style with the given StylevoidsetDraggable(boolean draggable) Indicates whether this component can be dragged in a drag and drop operation rather than scroll the parentvoidsetDragTransparency(byte dragTransparency) Sets the translucency of the#getDragImage()method.voidsetDropTarget(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 targetvoidsetEditingDelegate(Editable editable) Sets the editing delegate for this component.voidsetEnabled(boolean enabled) Indicates whether component is enabled or disabled thus allowing us to prevent a component from receiving input events and indicate so visuallyvoidsetFlatten(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.voidsetFocus(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 voidsetFocusable(boolean focusable) A simple setter to determine if this Component can get focusedvoidsetGrabsPointerEvents(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.voidsetHandlesInput(boolean handlesInput) Prevents key events from being grabbed for focus traversal.voidsetHeight(int height) Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly.voidsetHidden(boolean b) Makes the components preferred size equal 0 when hidden and restores it to the default size when not.voidsetHidden(boolean b, boolean changeMargin) Makes the components preferred size equal 0 when hidden and restores it to the default size when not.voidsetHideInLandscape(boolean hideInLandscape) Indicates that this component and all its children should be hidden when the device is switched to landscape modevoidsetHideInPortrait(boolean hideInPortrait) Indicates that this component and all its children should be hidden when the device is switched to portrait modevoidsetIgnorePointerEvents(boolean ignorePointerEvents) Parameters
protected voidsetInitialized(boolean initialized) Indicates if the component is in the initialized state, a component is initialized when its initComponent() method was invoked.voidsetInlineAllStyles(String styles) Registers inline styles that should be applied to all states of the component.voidsetInlineDisabledStyles(String styles) Registers inline styles that should be applied to the disabled state of the component.voidsetInlinePressedStyles(String styles) Registers inline styles that should be applied to the pressed state of the component.voidsetInlineSelectedStyles(String styles) Registers inline styles that should be applied to the selected state of the component.voidsetInlineStylesTheme(Resources inlineStylesTheme) Sets the theme that is used by inline styles to reference images.voidsetInlineUnselectedStyles(String styles) Registers inline styles that should be applied to the unselected state of the component.voidsetIsScrollVisible(boolean isScrollVisible) Set whether this component scroll is visiblevoidsetLabelForComponent(Label componentLabel) Allows us to indicate the label associated with this component thus providing visual feedback related for this component e.g.voidA component name allows us to easily identify the component within a dynamic UI.voidsetNextFocusDown(Component nextFocusDown) Allows us to determine which component will receive focus next when traversing with the down keyvoidsetNextFocusLeft(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.voidsetNextFocusRight(Component nextFocusRight) Allows us to determine which component will receive focus next when traversing with the right keyvoidsetNextFocusUp(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.final voidsetOpaque(boolean opaque) Sets whether or not to paint the component background.voidSets the owner of this component to the specified component.voidsetPinchBlocksDragAndDrop(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).voidsetPreferredH(int preferredH) Helper method to set the preferred height of the component.voidSets the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size.voidsetPreferredSizeStr(String value) Parameters
voidsetPreferredTabIndex(int index) Sets the preferred tab index of the component.voidsetPreferredW(int preferredW) Helper method to set the preferred width of the component.voidsetPressedStyle(Style style) Sets the Component Style for the pressed state allowing us to manipulate the look of the component when it is pressedsetPropertyValue(String name, Object value) Sets a new value to the given property, returns an error message if failed and null if successful.voidsetRippleEffect(boolean rippleEffect) Indicates whether the component displays the material design ripple effectvoidsetRTL(boolean rtl) Is the component a bidi RTL componentstatic voidsetSameHeight(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.static voidsetSameSize(Component... c) This is identical to invoking#sameWidthfollowed by#sameHeightstatic voidsetSameWidth(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.voidsetScrollAnimationSpeed(int animationSpeed) Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation modevoidsetScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed) Indicates the decrement units for the scroll opacityvoidSet the size for the scroll areavoidsetScrollVisible(boolean isScrollVisible) Set whether this component scroll is visibleprotected voidsetScrollX(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 voidsetScrollY(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.voidsetSelectCommandText(String selectText) Allows determining the text for the select command used in the 3rd softbutton mode.voidsetSelectedStyle(Style style) Changes the Component selected Style by replacing the Component Style with the given StylevoidsetShouldCalcPreferredSize(boolean shouldCalcPreferredSize) Indicates the values within the component have changed and preferred size should be recalculatedvoidSets the Component size, this method is exposed for the purpose of external layout managers and should not be invoked directly.voidsetSmoothScrolling(boolean smoothScrolling) Indicates that scrolling through the component should work as an animationvoidsetSnapToGrid(boolean snapToGrid) Indicates whether scrolling this component should jump to a specific location in a gridvoidsetTabIndex(int index) Sets the tab index of the component.voidsetTactileTouch(boolean tactileTouch) Indicates whether the component should "trigger" tactile touch when pressed by the user in a touch screen UI.voidsetTensileDragEnabled(boolean tensileDragEnabled) Indicates whether tensile drag (dragging beyond the boundry of the component and snapping back) is enabled for this component.voidsetTensileLength(int tensileLength) Recommended length for the tensile, -1 for defaultvoidsetTooltip(String tooltip) Parameters
final voidsetTraversable(boolean traversable) Sets whether this component is traversable using the keyboard using tab, next, previous keys.voidThis method sets the Component the Unique identifier.voidThis method sets the Component the Unique identifier.protected final voidsetUIIDFinal(String id) This method is the implementation of setUIID and is defined as final to allow invocation from constructors.voidsetUnselectedStyle(Style style) Changes the Component Style by replacing the Component Style with the given StylevoidsetVisible(boolean visible) Toggles visibility of the componentvoidsetWidth(int width) Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly.voidsetX(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.voidsetY(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 booleanA 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 booleanA 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 booleanA 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 booleanA 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 voidCreates the native overlay for this component.voidIf the component#isEditable(), then this will start the editing process.voidstopEditing(Runnable onFinish) Stops the editing process.Convenience method that strips margin and padding from the component, and returns itself for chaining.voidstyleChanged(String propertyName, Style source) Invoked to indicate a change in a propertyName of a StyletoImage()Returns the component as an image.toString()Overriden to return a useful value for debugging purposesvoidunbindProperty(String prop, BindTarget target) Removes a bind target from the given property nameprotected voidUpdates the native overlay for this component.booleanvisibleBoundsContains(int x, int y) Returns true if the given absolute coordinate is contained inside the visible bounds of the component.
-
Field Details
-
DEFAULT_CURSOR
public static final int DEFAULT_CURSORThe default cursor- See Also:
-
CROSSHAIR_CURSOR
public static final int CROSSHAIR_CURSORThe crosshair cursor type.- See Also:
-
TEXT_CURSOR
public static final int TEXT_CURSORThe text cursor type.- See Also:
-
WAIT_CURSOR
public static final int WAIT_CURSORThe wait cursor type.- See Also:
-
SW_RESIZE_CURSOR
public static final int SW_RESIZE_CURSORThe south-west-resize cursor type.- See Also:
-
SE_RESIZE_CURSOR
public static final int SE_RESIZE_CURSORThe south-east-resize cursor type.- See Also:
-
NW_RESIZE_CURSOR
public static final int NW_RESIZE_CURSORThe north-west-resize cursor type.- See Also:
-
NE_RESIZE_CURSOR
public static final int NE_RESIZE_CURSORThe north-east-resize cursor type.- See Also:
-
N_RESIZE_CURSOR
public static final int N_RESIZE_CURSORThe north-resize cursor type.- See Also:
-
S_RESIZE_CURSOR
public static final int S_RESIZE_CURSORThe south-resize cursor type.- See Also:
-
W_RESIZE_CURSOR
public static final int W_RESIZE_CURSORThe west-resize cursor type.- See Also:
-
E_RESIZE_CURSOR
public static final int E_RESIZE_CURSORThe east-resize cursor type.- See Also:
-
HAND_CURSOR
public static final int HAND_CURSORThe hand cursor type.- See Also:
-
MOVE_CURSOR
public static final int MOVE_CURSORThe move cursor type.- See Also:
-
DRAG_REGION_NOT_DRAGGABLE
public static final int DRAG_REGION_NOT_DRAGGABLEUsed by getDragRegionStatus to indicate no dragability- See Also:
-
DRAG_REGION_POSSIBLE_DRAG_X
public static final int DRAG_REGION_POSSIBLE_DRAG_XUsed by getDragRegionStatus to indicate limited dragability- See Also:
-
DRAG_REGION_POSSIBLE_DRAG_Y
public static final int DRAG_REGION_POSSIBLE_DRAG_YUsed by getDragRegionStatus to indicate limited dragability- See Also:
-
DRAG_REGION_POSSIBLE_DRAG_XY
public static final int DRAG_REGION_POSSIBLE_DRAG_XYUsed by getDragRegionStatus to indicate limited dragability- See Also:
-
DRAG_REGION_LIKELY_DRAG_X
public static final int DRAG_REGION_LIKELY_DRAG_XUsed by getDragRegionStatus to indicate likely dragability- See Also:
-
DRAG_REGION_LIKELY_DRAG_Y
public static final int DRAG_REGION_LIKELY_DRAG_YUsed by getDragRegionStatus to indicate likely dragability- See Also:
-
DRAG_REGION_LIKELY_DRAG_XY
public static final int DRAG_REGION_LIKELY_DRAG_XYUsed by getDragRegionStatus to indicate likely dragability- See Also:
-
DRAG_REGION_IMMEDIATELY_DRAG_X
public static final int DRAG_REGION_IMMEDIATELY_DRAG_XUsed by getDragRegionStatus to indicate immediate dragability- See Also:
-
DRAG_REGION_IMMEDIATELY_DRAG_Y
public static final int DRAG_REGION_IMMEDIATELY_DRAG_YUsed by getDragRegionStatus to indicate immediate dragability- See Also:
-
DRAG_REGION_IMMEDIATELY_DRAG_XY
public static final int DRAG_REGION_IMMEDIATELY_DRAG_XYUsed by getDragRegionStatus to indicate immediate dragability- See Also:
-
BRB_CONSTANT_ASCENT
public static final int BRB_CONSTANT_ASCENTBaseline 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_DESCENTBaseline 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_OFFSETBaseline 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_OTHERBaseline 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 CENTERIndicates a Component center alignment- See Also:
-
TOP
public static final int TOPBox-orientation constant used to specify the top of a box.- See Also:
-
LEFT
public static final int LEFTBox-orientation constant used to specify the left side of a box.- See Also:
-
BOTTOM
public static final int BOTTOMBox-orientation constant used to specify the bottom of a box.- See Also:
-
RIGHT
public static final int RIGHTBox-orientation constant used to specify the right side of a box.- See Also:
-
BASELINE
public static final int BASELINEAlignment to the baseline constraint- See Also:
-
-
Constructor Details
-
Component
protected Component()Creates a new instance of Component
-
-
Method Details
-
setSameSize
This is identical to invoking
#sameWidthfollowed by#sameHeightParameters
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
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
Gets the delegate that handles the editing of this component.
Returns
The editing delegate for this component.
Since
6.0
-
setEditingDelegate
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
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
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
Returns the array of components that have an equal width
Returns
components in the same width group
-
setSameWidth
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
Returns the array of components that have an equal height
Returns
components in the same height group
-
setSameHeight
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
This method initializes the Component defaults constants -
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
-
getInlineAllStyles
Gets inline styles that are to be applied to all states of this component.
Returns
Inline styles applied to all states.
-
setInlineAllStyles
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
Gets inline styles that are to be applied to the selected state of this component.
Returns
Inline styles applied to selected state
-
setInlineSelectedStyles
Registers inline styles that should be applied to the selected state of the component.
Parameters
styles: style format
See also
- #setInlineAllStyles(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
Registers inline styles that should be applied to the unselected state of the component.
Parameters
styles: style format
See also
- #setInlineAllStyles(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
Registers inline styles that should be applied to the disabled state of the component.
Parameters
styles: style format
See also
- #setInlineAllStyles(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
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
Returns the container in which this component is contained
Returns
the parent container in which this component is contained
-
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
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. Theint)method is used instead ofint)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
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
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
Deregisters interest in receiving callbacks for focus gained events
Parameters
l: listener interface implementing the observable pattern
-
addScrollListener
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
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
Allows determining the text for the select command used in the 3rd softbutton mode.
Returns
text for the interaction with the softkey
-
setSelectCommandText
Allows determining the text for the select command used in the 3rd softbutton mode.
Parameters
selectText: text for the interaction with the softkey
-
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
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
This method paints all the parents Components Background.
Parameters
g: the graphics object
-
paintShadows
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
-
paintIntersectingComponentsAbove
Paints intersecting components that appear above this component.
Parameters
g: Graphics context
Deprecated
For internal use only
-
paintScrollbars
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
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
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
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
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
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
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
Returns the scrollable parent of this component
Returns
the component itself or its parent which is scrollable
-
paintBackground
This method paints the Component background, it should be overriden by subclasses to perform custom background drawing.
Parameters
g: the component graphics
-
paint
-
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
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
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
-
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
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 orContainer#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 ajava.util.ListIteratorof 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 thecom.codename1.ui.layouts.Layout#overridesTabIndices(com.codename1.ui.Container)andcom.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
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
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
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
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
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
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
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
-
draggingOver
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
This callback method indicates that a component drag has just entered this component
Parameters
dragged: the component being dragged
-
dragExit
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
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
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
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
Binds an action listener to drop events which are invoked when this component is dropped on a target
Parameters
l: the callback
-
removeDropListener
Removes an action listener to drop events which are invoked when this component is dropped on a target
Parameters
l: the callback
-
addDragOverListener
Broadcasts an event when dragging over a component
Parameters
l: the listener
-
removeDragOverListener
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
Adds a listener to the dragFinished event
Parameters
l: callback to receive drag finished events events
-
addStateChangeListener
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
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
Adds a listener to the pointer event
Parameters
l: callback to receive pointer events
-
addLongPressListener
Adds a listener to the pointer event
Parameters
l: callback to receive pointer events
Since
7.0
-
paintRippleOverlay
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
Removes the listener from the pointer event
Parameters
l: callback to remove
-
removeLongPressListener
Removes the listener from the pointer event
Parameters
l: callback to remove
Since
7.0
-
removeDragFinishedListener
Removes the listener from the drag finished event
Parameters
l: callback to remove
-
addPointerReleasedListener
Adds a listener to the pointer event
Parameters
l: callback to receive pointer events
-
removePointerReleasedListener
Removes the listener from the pointer event
Parameters
l: callback to remove
-
addPointerDraggedListener
Adds a listener to the pointer event
Parameters
l: callback to receive pointer events
-
removePointerDraggedListener
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
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
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
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
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
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
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
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
Returns the Component Style for the unselected mode allowing us to manipulate the look of the component
Returns
the component Style object
-
setUnselectedStyle
Changes the Component Style by replacing the Component Style with the given Style
Parameters
style: the component Style object
-
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
Changes the Component selected Style by replacing the Component Style with the given Style
Parameters
style: the component Style object
-
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
Changes the Component disalbed Style by replacing the Component Style with the given Style
Parameters
style: the component Style object
-
installDefaultPainter
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
-
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
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.Displayclass.Returns
true if a repaint is desired or false if no repaint is necessary
-
scrollRectToVisible
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
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
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
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:
startEditingAsyncin interfaceEditable
-
-
stopEditing
Stops the editing process.
Parameters
onFinish: Callback called when the editing is complete.
See also
-
#startEditingAsync()
-
#isEditing()
-
#isEditable()
-
#getEditingDelegate()
-
#setEditingDelegate(com.codename1.ui.Editable)
- Specified by:
stopEditingin interfaceEditable
-
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)
-
-
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:
isEditablein interfaceEditable
-
-
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
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 callingCN.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:
styleChangedin interfaceStyleListener
-
-
getNextFocusDown
Allows us to determine which component will receive focus next when traversing with the down key
Returns
the next focus component
-
setNextFocusDown
Allows us to determine which component will receive focus next when traversing with the down key
Parameters
nextFocusDown: the next focus component
-
getNextFocusUp
Allows us to determine which component will receive focus next when traversing with the up key.
Returns
the nxt focus component
-
setNextFocusUp
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
Allows us to determine which component will receive focus next when traversing with the left key.
Returns
the next focus component
-
setNextFocusLeft
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
Allows us to determine which component will receive focus next when traversing with the right key
Returns
the next focus component
-
setNextFocusRight
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
A component name allows us to easily identify the component within a dynamic UI.
Returns
name of the component
-
setName
A component name allows us to easily identify the component within a dynamic UI.
Parameters
name: a name for the component
-
initCustomStyle
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
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
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
Matches the property names method (see that method for further details).
Returns
the types of the properties
-
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
-
setPropertyValue
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
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
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
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
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
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
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
-
setBoundPropertyValue
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
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
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
The destination property of the CloudObject
Returns
the cloudDestinationProperty
Deprecated
this mapped to an older iteration of properties that is no longer used
-
setCloudDestinationProperty
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
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
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
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
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
nullif none -
setAccessibilityText
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
Returns
the tooltip
-
setTooltip
Parameters
tooltip: the tooltip to set
-