Class Button
- All Implemented Interfaces:
Animation, Editable, ActionSource<ActionEvent>, StyleListener, IconHolder, ReleasableComponent, SelectableIconHolder, TextHolder
- Direct Known Subclasses:
CheckBox, FloatingActionButton, LikeButton, Picker, RadioButton, ScaleImageButton, ShareButton
Button is the base class for several UI widgets allowing clickability.
It has 3 states: rollover, pressed and the default state. Button
can also have an com.codename1.ui.events.ActionListener that react when the
Button is clicked or handle actions via a
com.codename1.ui.Command.
Button has the "Button" UIID by default.
Here is trivial usage of the Button API:
Form hi = new Form("Button");
Button b = new Button("My Button");
hi.add(b);
b.addActionListener((e) -> Log.p("Clicked"));
This code shows a common use case of making a button look like a hyperlink
Form hi = new Form("Button");
Button b = new Button("Link Button");
b.getAllStyles().setBorder(Border.createEmpty());
b.getAllStyles().setTextDecoration(Style.TEXT_DECORATION_UNDERLINE);
hi.add(b);
b.addActionListener((e) -> Log.p("Clicked"));
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates the default state of a button which is neither pressed nor focusedstatic final intIndicates the pressed state of a buttonstatic final intIndicates the rollover state of a button which is equivalent to focused for most usesFields inherited from class Component
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR -
Constructor Summary
ConstructorsConstructorDescriptionButton()Constructs a button with an empty string for its text.Button(char icon) Constructs a button with the specified material image icon.Constructor a button with material image icon and UIIDConstructor a button with material image icon and UIIDAllows binding a command to a button for ease of useConstructs a button with the specified image.Constructor a button with image and UIIDConstructs a button with the specified text.Constructor a button with text, material image and uiidConstructor a button with text, material image and uiidConstructor a button with text and imageConstructor a button with text, image and uiidConstructor a button with text and UIID -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener to the button which will cause an event to dispatch on clickvoidAdds a listener to be notified when the button state changes.booleananimate()Allows the animation to reduce "repaint" calls when it returns false.voidbindStateTo(Button button) Bind the state of this button to another button's state.protected DimensionCalculates the preferred size based on component content.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 voidfireActionEvent(int x, int y) Allows subclasses to override action event behavior
Parameters
-
x: the x position of the click if applicable (can be 0 or -1 otherwise) -
y: the y position of the click if applicable (can be 0 or -1 otherwise)
protected 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.Returns a vector containing the action listeners for this buttonprotected BorderNormally returns getStyle().getBorder() but some subclasses might use this to programmatically replace the border in runtime e.g.This method return the Button Command if existsIndicates the icon that is displayed on the button when the button is in the disabled stateReturns the icon for the button based on its current stateReturns a collection containing the action listeners for this buttonIndicates the icon that is displayed on the button when the button is in pressed stateintIndicates a radius in which a pointer release will still have effect.Indicates the icon that is displayed on the button when the button is in rolled over stateIndicates the icon that is displayed on the button when the button is in pressed state and is selected.intgetState()Returns the button statebooleanReturns if this is an auto released Button.static booleanDefault value for the button ripple effect, this can be set with the theme constant buttonRippleBoolfinal booleanIndicates whether text on the button should be drawn capitalized by default to match the Android design.static booleanIndicates whether text on the button should be drawn capitalized by default to match the Android design.booleanPlaces the check box or radio button on the opposite side at the far endprotected 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.booleanReturns true if the button is selected for toggle buttons,booleanisToggle()Toggle button mode is only relevant for checkboxes/radio buttons.voidkeyPressed(int keyCode) If this Component is focused, the key pressed event will call this methodvoidkeyReleased(int keyCode) If this Component is focused, the key released event will call this methodvoidkeyRepeated(int keyCode) If this Component is focused, the key repeat event will call this method.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.voidpointerHover(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerHoverReleased(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerPressed(int x, int y) If this Component is focused, the pointer pressed event will call this methodvoidpointerReleased(int x, int y) If this Component is focused, the pointer released event will call this methodvoidpressed()Invoked to change the state of the button to the pressed statevoidreleased()Invoked to change the state of the button to the released statevoidreleased(int x, int y) Invoked to change the state of the button to the released statevoidRemoves the given action listener from the buttonvoidRemoves state change listener.protected voidRestores the state of the focusable flag to its default statevoidsetAlignment(int align) Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHTvoidsetAutoRelease(boolean autoRelease) Sets the auto released mode of this button, by default it's not an auto released Buttonstatic voidsetButtonRippleEffectDefault(boolean aButtonRippleEffectDefault) Default value for the button ripple effect, this can be set with the theme constant buttonRippleBoolvoidsetCapsText(boolean capsText) Indicates whether text on the button should be drawn capitalized by default to match the Android design.static voidsetCapsTextDefault(boolean aCapsTextDefault) Indicates whether text on the button should be drawn capitalized by default to match the Android design This value can be set by thecapsButtonTextBooltheme constantvoidsetCommand(Command cmd) Applies the given command to this buttonvoidsetDisabledIcon(Image disabledIcon) Indicates the icon that is displayed on the button when the button is in the disabled statevoidsetPressedIcon(Image pressedIcon) Indicates the icon that is displayed on the button when the button is in pressed statevoidSet the button in released and unfocused statevoidsetReleaseRadius(int releaseRadius) Indicates a radius in which a pointer release will still have effect.voidsetRolloverIcon(Image rolloverIcon) Indicates the icon that is displayed on the button when the button is in rolled over statevoidsetRolloverPressedIcon(Image rolloverPressedIcon) Indicates the icon that is displayed on the button when the button is in pressed state and is selected.voidOverriden to implement the caps mode#setCapsText(boolean)Sets the Label textvoidsetToggle(boolean toggle) Toggle button mode is only relevant for checkboxes/radio buttons.voidOverriden to workaround issue with caps text and different UIID's This method sets the Component the Unique identifier.voidunbindStateFrom(Button button) Unbinds the state of this button from another button.Methods inherited from class Label
bindProperty, getAlignment, getBadgeStyleComponent, getBadgeText, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue, getDefaultGap, getFontIcon, getFontIconSize, getGap, getIcon, getIconFont, getIconStyleComponent, getIconUIID, getMask, getMaskedIcon, getMaskName, getMaterialIcon, getMaterialIconSize, getMaxAutoSize, getMinAutoSize, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getShiftMillimeters, getShiftMillimetersF, getShiftText, getStringWidth, getText, getTextPosition, getTextSelectionSupport, getVerticalAlignment, initLaf, initUnselectedStyle, isAutoSizeMode, isDefaultTickerEnabled, isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank, isTextSelectionEnabled, isTickerEnabled, isTickerRunning, laidOut, paramString, refreshTheme, setAutoSizeMode, setBadgeText, setBadgeUIID, setBoundPropertyValue, setDefaultGap, setDefaultTickerEnabled, setEndsWith3Points, setFontIcon, setFontIcon, setFontIcon, setGap, setIcon, setIconUIID, setLegacyRenderer, setMask, setMaskName, setMaterialIcon, setMaterialIcon, setMaxAutoSize, setMinAutoSize, setPropertyValue, setShiftMillimeters, setShiftMillimeters, setShiftText, setShouldLocalize, setShowEvenIfBlank, setTextPosition, setTextSelectionEnabled, setTickerEnabled, setVerticalAlignment, shouldTickerStart, startTicker, startTicker, stopTicker, styleChanged, unbindPropertyMethods inherited from class Component
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, announceForAccessibility, blocksSideSwipe, calcScrollSize, cancelRepaints, clearClientProperties, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAccessibilityText, getAllStyles, getAnimationManager, getBottomGap, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getGridPosX, getGridPosY, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getStyle, getTabIndex, getTensileLength, getTooltip, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, longKeyPress, longPointerPress, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, repaint, repaint, requestFocus, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAccessibilityText, setAlwaysTensile, setBlockLead, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIIDFinal, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, toImage, toString, updateNativeOverlay, visibleBoundsContainsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface IconHolder
getGap, getIcon, getIconStyleComponent, getIconUIID, getTextPosition, setFontIcon, setGap, setIcon, setIconUIID, setMaterialIcon, setTextPosition -
-
Field Details
-
STATE_ROLLOVER
public static final int STATE_ROLLOVERIndicates the rollover state of a button which is equivalent to focused for most uses- See Also:
-
STATE_PRESSED
public static final int STATE_PRESSEDIndicates the pressed state of a button- See Also:
-
STATE_DEFAULT
public static final int STATE_DEFAULTIndicates the default state of a button which is neither pressed nor focused- See Also:
-
-
Constructor Details
-
Button
public Button()Constructs a button with an empty string for its text. -
Button
Constructs a button with the specified text.
Parameters
text: label appearing on the button
-
Button
Allows binding a command to a button for ease of use
Parameters
cmd: @param cmd command whose text would be used for the button and would recive action events from the button
-
Button
Constructs a button with the specified image.
Parameters
icon: appearing on the button
-
Button
public Button(char icon) Constructs a button with the specified material image icon.
Parameters
icon: appearing on the button
-
Button
-
Button
-
Button
-
Button
-
Button
-
Button
Constructor a button with material image icon and UIID
Parameters
-
icon: image appearing on the button -
id: UIID unique identifier for button
-
-
Button
Constructor a button with material image icon and UIID
Parameters
-
icon: image appearing on the button -
iconSize: the size of the icon in millimeters -
id: UIID unique identifier for button
-
-
Button
-
-
Method Details
-
isCapsTextDefault
public static boolean isCapsTextDefault()Indicates whether text on the button should be drawn capitalized by default to match the Android design. This value can be set by the
capsButtonTextBooltheme constantReturns
the capsTextDefault
-
setCapsTextDefault
public static void setCapsTextDefault(boolean aCapsTextDefault) Indicates whether text on the button should be drawn capitalized by default to match the Android design This value can be set by the
capsButtonTextBooltheme constantParameters
aCapsTextDefault: the capsTextDefault to set
-
isButtonRippleEffectDefault
public static boolean isButtonRippleEffectDefault()Default value for the button ripple effect, this can be set with the theme constant buttonRippleBool
Returns
the buttonRippleEffectDefault
-
setButtonRippleEffectDefault
public static void setButtonRippleEffectDefault(boolean aButtonRippleEffectDefault) Default value for the button ripple effect, this can be set with the theme constant buttonRippleBool
Parameters
aButtonRippleEffectDefault: the buttonRippleEffectDefault to set
-
bindStateTo
Bind the state of this button to another button's state. Once bound, when the other button's state changes, this button will change its state to match.
Parameters
button: The button whose state to bind to.
Since
7.0
See also
- #unbindStateFrom(com.codename1.ui.Button)
-
unbindStateFrom
Unbinds the state of this button from another button.
Parameters
button: The button to unbind state from.
Since
7.0
See also
- #bindStateTo(com.codename1.ui.Button)
-
resetFocusable
protected void resetFocusable()Restores the state of the focusable flag to its default state- Overrides:
resetFocusablein classComponent
-
getState
public int getState()Returns the button state
Returns
One of STATE_ROLLOVER, STATE_DEAFULT, STATE_PRESSED
-
setReleased
public void setReleased()Set the button in released and unfocused state- Specified by:
setReleasedin interfaceReleasableComponent
-
getPressedIcon
Indicates the icon that is displayed on the button when the button is in pressed state
Returns
icon used
See also
- #STATE_PRESSED
- Specified by:
getPressedIconin interfaceSelectableIconHolder
-
setPressedIcon
Indicates the icon that is displayed on the button when the button is in pressed state
Parameters
pressedIcon: icon used
See also
- #STATE_PRESSED
- Specified by:
setPressedIconin interfaceSelectableIconHolder
-
getRolloverPressedIcon
Indicates the icon that is displayed on the button when the button is in pressed state and is selected. This is ONLY applicable to toggle buttons
Returns
icon used
- Specified by:
getRolloverPressedIconin interfaceSelectableIconHolder
-
setRolloverPressedIcon
Indicates the icon that is displayed on the button when the button is in pressed state and is selected. This is ONLY applicable to toggle buttons
Parameters
rolloverPressedIcon: icon used
- Specified by:
setRolloverPressedIconin interfaceSelectableIconHolder
-
getDisabledIcon
Indicates the icon that is displayed on the button when the button is in the disabled state
Returns
icon used
- Specified by:
getDisabledIconin interfaceSelectableIconHolder
-
setDisabledIcon
Indicates the icon that is displayed on the button when the button is in the disabled state
Parameters
disabledIcon: icon used
- Specified by:
setDisabledIconin interfaceSelectableIconHolder
-
getRolloverIcon
Indicates the icon that is displayed on the button when the button is in rolled over state
Returns
icon used
See also
- #STATE_ROLLOVER
- Specified by:
getRolloverIconin interfaceSelectableIconHolder
-
setRolloverIcon
Indicates the icon that is displayed on the button when the button is in rolled over state
Parameters
rolloverIcon: icon to use
See also
- #STATE_ROLLOVER
- Specified by:
setRolloverIconin interfaceSelectableIconHolder
-
addStateChangeListener
Adds a listener to be notified when the button state changes.
Parameters
l: Listener to be notified when state changes
Since
7.0
See also
-
#getState()
-
#setState(int)
-
#removeStateChangeListener(com.codename1.ui.events.ActionListener)
- Overrides:
addStateChangeListenerin classComponent
-
removeStateChangeListener
Removes state change listener.
Parameters
l: State change listener to remove.
Since
7.0
See also
-
#addStateChangeListener(com.codename1.ui.events.ActionListener)
-
#getState()
-
#setState(int)
- Overrides:
removeStateChangeListenerin classComponent
-
addActionListener
Adds a listener to the button which will cause an event to dispatch on click
Parameters
l: implementation of the action listener interface
- Specified by:
addActionListenerin interfaceActionSource<ActionEvent>
-
removeActionListener
Removes the given action listener from the button
Parameters
l: implementation of the action listener interface
- Specified by:
removeActionListenerin interfaceActionSource<ActionEvent>
-
getActionListeners
Returns a vector containing the action listeners for this button
Returns
the action listeners
Deprecated
use getListeners instead
-
getListeners
Returns a collection containing the action listeners for this button
Returns
the action listeners
-
getIconFromState
Returns the icon for the button based on its current state
Returns
the button icon based on its current state
- Specified by:
getIconFromStatein interfaceSelectableIconHolder
-
fireActionEvent
protected void fireActionEvent(int x, int y) Allows subclasses to override action event behavior
Parameters
-
x: the x position of the click if applicable (can be 0 or -1 otherwise) -
y: the y position of the click if applicable (can be 0 or -1 otherwise)
-
-
pressed
public void pressed()Invoked to change the state of the button to the pressed state -
released
public void released()Invoked to change the state of the button to the released state -
released
public void released(int x, int y) Invoked to change the state of the button to the released state
Parameters
-
x: the x position if a touch event triggered this, -1 if this isn't relevant -
y: the y position if a touch event triggered this, -1 if this isn't relevant
-
-
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.
- Overrides:
keyPressedin classComponent
-
keyReleased
public void keyReleased(int keyCode) If this Component is focused, the key released event will call this method
Parameters
keyCode: the key code value to indicate a physical key.
- Overrides:
keyReleasedin classComponent
-
keyRepeated
public void keyRepeated(int keyCode) If this Component is focused, the key repeat event will call this method.
Parameters
keyCode: the key code value to indicate a physical key.
- Overrides:
keyRepeatedin classComponent
-
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.- Overrides:
fireClickedin classComponent
-
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
- Overrides:
isSelectableInteractionin classComponent
-
pointerHover
public void pointerHover(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display. This is true for PC mouse pointer as well as some devices such as the BB storm.
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerHoverin classComponent
-
-
pointerHoverReleased
public void pointerHoverReleased(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display. This is true for PC mouse pointer as well as some devices such as the BB storm.
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerHoverReleasedin classComponent
-
-
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
- Overrides:
pointerPressedin classComponent
-
-
pointerReleased
public void pointerReleased(int x, int y) If this Component is focused, the pointer released event will call this method
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerReleasedin classComponent
-
-
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- Overrides:
dragInitiatedin classComponent
-
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
- Overrides:
calcPreferredSizein classLabel
-
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
-
getCommand
This method return the Button Command if exists
Returns
Command Object or null if a Command not exists
-
setCommand
Applies the given command to this button
Parameters
cmd: the command on the button
-
isSelected
public boolean isSelected()Returns true if the button is selected for toggle buttons,
Returns
true if the button is selected
-
setAlignment
public void setAlignment(int align) Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
Parameters
align: alignment value
Deprecated
use Style.setAlignment instead
See also
-
#CENTER
-
#LEFT
-
#RIGHT
Deprecated
use the Style alignment instead
- Overrides:
setAlignmentin classLabel
-
isToggle
public boolean isToggle()Toggle button mode is only relevant for checkboxes/radio buttons. When pressed a toggle button stays pressed and when pressed again it moves to releleased state.
Returns
the toggle
-
setToggle
public void setToggle(boolean toggle) Toggle button mode is only relevant for checkboxes/radio buttons. When pressed a toggle button stays pressed and when pressed again it moves to releleased state. Setting toggle implicitly changes the UIID to "ToggleButton"
Parameters
toggle: the toggle to set
-
setUIID
Overriden to workaround issue with caps text and different UIID's
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
-
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
-
isOppositeSide
public boolean isOppositeSide()Places the check box or radio button on the opposite side at the far end
Returns
the oppositeSide
-
getReleaseRadius
public int getReleaseRadius()Indicates a radius in which a pointer release will still have effect. Notice that this only applies to pointer release events and not to pointer press events
Returns
the releaseRadius
- Specified by:
getReleaseRadiusin interfaceReleasableComponent
-
setReleaseRadius
public void setReleaseRadius(int releaseRadius) Indicates a radius in which a pointer release will still have effect. Notice that this only applies to pointer release events and not to pointer press events
Parameters
releaseRadius: the releaseRadius to set
- Specified by:
setReleaseRadiusin interfaceReleasableComponent
-
isAutoRelease
public boolean isAutoRelease()Returns if this is an auto released Button. Auto released Buttons will are been disarmed when a drag is happening within the Button.
Returns
true if it's an auto released Button.
- Specified by:
isAutoReleasein interfaceReleasableComponent
-
setAutoRelease
public void setAutoRelease(boolean autoRelease) Sets the auto released mode of this button, by default it's not an auto released Button- Specified by:
setAutoReleasein interfaceReleasableComponent
-
paint
Description copied from class:LabelThis method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.
Parameters
g: the component graphics
-
isCapsText
public final boolean isCapsText()Indicates whether text on the button should be drawn capitalized by default to match the Android design. By default only
ButtonandRaisedButtonwill be capped to keep compatibility. You can add additional UIID's to the mix by using the theme constantcapsButtonUiidswhich can include a separated list of the UIID's to capitalizeReturns
the capsText
-
setCapsText
public void setCapsText(boolean capsText) Indicates whether text on the button should be drawn capitalized by default to match the Android design. By default only
ButtonandRaisedButtonwill be capped to keep compatibility. You can add additional UIID's to the mix by using the theme constantcapsButtonUiidswhich can include a separated list of the UIID's to capitalizeParameters
capsText: the capsText to set
-
setText
Overriden to implement the caps mode
#setCapsText(boolean)Sets the Label text
Parameters
text: the string that the label presents.
- Specified by:
setTextin interfaceTextHolder- Overrides:
setTextin classLabel
-