public class SpanButton extends Container implements ActionSource, SelectableIconHolder, TextHolder
A complex button similar to MultiButton that breaks lines automatically and looks like a regular button (more or less). Unlike the multi button the span button has the UIID style of a button.

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 and Description |
|---|
SpanButton()
Default constructor will be useful when adding this to the GUI builder
|
SpanButton(String txt)
Constructor accepting default text
|
SpanButton(String txt,
String textUiid)
Constructor accepting default text and uiid for the text
|
| Modifier and Type | Method and Description |
|---|---|
void |
addActionListener(ActionListener l)
Binds an action listener to button events
|
void |
addLongPressListener(ActionListener l)
Binds long press listener to button events.
|
Command |
getCommand()
Returns the command instance of the button
|
Image |
getDisabledIcon()
Returns the disabled icon of the button
|
char |
getFontIcon()
Returns the font icon assigned to this component or 0 if not applicable
|
float |
getFontIconSize()
Returns the icon size assigned to this component or 0/-1 if
not applicable
|
int |
getGap()
Returns the gap in pixels between the icon/text to the Label boundaries
|
Image |
getIcon()
Returns the image of the icon
|
Font |
getIconFont()
Returns the font for the icon font or null if not font set
|
Image |
getIconFromState()
Returns the icon for the button based on its current state
|
String |
getIconPosition()
Returns the icon position based on border layout constraints
|
Component |
getIconStyleComponent()
Gets the component used for styling font icons on this SpanLabel.
|
String |
getIconUIID()
Returns the UIID for the icon
|
char |
getMaterialIcon()
Returns the material icon assigned to this component or 0 if not applicable
|
float |
getMaterialIconSize()
Returns the material icon size assigned to this component or 0/-1 if
not applicable
|
Image |
getPressedIcon()
Returns the pressed icon of the button
|
String[] |
getPropertyNames()
A component may expose mutable property names for a UI designer to manipulate, this
API is designed for usage internally by the GUI builder code
|
String[] |
getPropertyTypeNames()
This method is here to workaround an XMLVM array type bug where property types aren't
identified properly, it returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,ListCellRenderer
|
Class[] |
getPropertyTypes()
Matches the property names method (see that method for further details).
|
Object |
getPropertyValue(String name)
Returns the current value of the property name, this method is used by the GUI builder
|
Image |
getRolloverIcon()
Returns the rollover icon of the button
|
Image |
getRolloverPressedIcon()
Indicates the icon that is displayed on the button when the button is in
pressed state and is selected.
|
String |
getText()
Returns the text of the button
|
Style |
getTextAllStyles()
Returns the Style proxy object for the text of this span button.
|
TextArea |
getTextComponent()
Returns the TextArea holding the actual text
|
int |
getTextPosition()
Returns The position of the text relative to the icon
|
Style |
getTextStyle()
Returns the Style object for the text of this span button.
|
String |
getTextUIID()
Returns the uiid of the actual text
|
boolean |
isAutoRelease()
Returns if this is an auto released Button.
|
boolean |
isShouldLocalize()
Indicates if text should be localized when set to the component, by
default all text is localized so this allows disabling automatic
localization for a specific component.
|
void |
removeActionListener(ActionListener l)
Removes the listener from tracking button events
|
void |
removeLongPressListener(ActionListener l)
Unbinds long press listener to button events.
|
void |
setAutoRelease(boolean autoRelease)
Sets the auto released mode of this button, by default it's not an auto
released Button
|
void |
setCommand(Command cmd)
Sets the command for the component
|
void |
setDisabledIcon(Image i)
Sets the disabled icon for the button
|
void |
setFontIcon(Font font,
char c)
This method is shorthand for
com.codename1.ui.FontImage#setMaterialIcon(com.codename1.ui.Label, com.codename1.ui.Font, char) |
void |
setFontIcon(Font font,
char c,
float size)
This method is shorthand for
FontImage.setFontIcon(com.codename1.ui.Label, com.codename1.ui.Font, char, float) |
void |
setGap(int gap)
Set the gap in pixels between the icon/text to the Label boundaries
|
void |
setIcon(Image i)
Sets the icon for the button
|
void |
setIconPosition(String t)
Sets the icon position based on border layout constraints
|
void |
setIconUIID(String uiid)
Sets the uiid for the icon if present
|
void |
setMaterialIcon(char c)
This method is shorthand for
FontImage.setMaterialIcon(com.codename1.ui.Label, char) |
void |
setMaterialIcon(char c,
float size)
This method is shorthand for
FontImage.setMaterialIcon(com.codename1.ui.Label, char, float) |
void |
setPressedIcon(Image i)
Sets the pressed icon for the button
|
String |
setPropertyValue(String name,
Object value)
Sets a new value to the given property, returns an error message if failed
and null if successful.
|
void |
setRolloverIcon(Image i)
Sets the rollover icon for the button
|
void |
setRolloverPressedIcon(Image arg0)
Indicates the icon that is displayed on the button when the button is in
pressed state and is selected.
|
void |
setShouldLocalize(boolean shouldLocalize)
Indicates if text should be localized when set to the component, by
default all text is localized so this allows disabling automatic
localization for a specific component.
|
void |
setText(String t)
Set the text of the button
|
void |
setTextPosition(int textPosition)
Sets the position of the text relative to the icon if exists
|
void |
setTextUIID(String uiid)
Sets the UIID for the actual text
|
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. |
add, add, add, add, add, add, addAll, addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize, cancelRepaints, clearClientProperties, constrainHeightWhenScrollable, constrainWidthWhenScrollable, contains, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayout, createAnimateLayoutFade, createAnimateLayoutFadeAndWait, createAnimateMotion, createAnimateUnlayout, createReplaceTransition, dragInitiated, drop, encloseIn, encloseIn, findDropTargetAt, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getChildrenAsList, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getResponderAt, getSafeAreaRoot, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isScrollableX, isScrollableY, isSelectableInteraction, iterator, iterator, keyPressed, keyReleased, layoutContainer, morph, morphAndWait, paint, paintComponentBackground, paintGlass, paramString, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, revalidateLater, revalidateWithAnimationSafety, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setSafeArea, setSafeAreaRoot, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager, updateTabIndicesaddDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, animate, bindProperty, blocksSideSwipe, calcScrollSize, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getEditingDelegate, 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, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, parsePreferredSize, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEditingDelegate, 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, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUnselectedStyle, setVisible, setX, setY, shouldBlockSideSwipe, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContainsclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic SpanButton()
public SpanButton(String txt, String textUiid)
txt - the texttextUiid - the new text UIIDpublic SpanButton(String txt)
public TextArea getTextComponent()
public void setTextUIID(String uiid)
uiid - the uiidpublic String getTextUIID()
public Component getIconStyleComponent()
getIconStyleComponent in interface IconHolderpublic Style getTextAllStyles()
public Style getTextStyle()
public void setIconUIID(String uiid)
setIconUIID in interface IconHolderuiid - the uiid for the iconpublic String getIconUIID()
getIconUIID in interface IconHolderpublic void setText(String t)
setText in interface TextHoldert - text of the buttonpublic void setIcon(Image i)
setIcon in interface IconHolderi - the iconpublic String getText()
getText in interface TextHolderpublic Image getIcon()
getIcon in interface IconHolderpublic void addLongPressListener(ActionListener l)
addLongPressListener in class Componentl - public void removeLongPressListener(ActionListener l)
removeLongPressListener in class Componentl - public void addActionListener(ActionListener l)
addActionListener in interface ActionSourcel - the listenerpublic void removeActionListener(ActionListener l)
removeActionListener in interface ActionSourcel - the listenerpublic void setIconPosition(String t)
s - position either North/South/East/Westpublic String getIconPosition()
public void setCommand(Command cmd)
cmd - the commandpublic Command getCommand()
public String[] getPropertyNames()
getPropertyNames in class Componentpublic Class[] getPropertyTypes()
getPropertyTypes in class Componentpublic String[] getPropertyTypeNames()
getPropertyTypeNames in class Componentpublic Object getPropertyValue(String name)
getPropertyValue in class Componentname - the name of the propertypublic String setPropertyValue(String name, Object value)
setPropertyValue in class Componentname - the name of the propertyvalue - new value for the propertypublic boolean isShouldLocalize()
public void setShouldLocalize(boolean shouldLocalize)
shouldLocalize - the shouldLocalize to setpublic void setPressedIcon(Image i)
setPressedIcon in interface SelectableIconHolderi - the iconButton.STATE_PRESSEDpublic Image getPressedIcon()
getPressedIcon in interface SelectableIconHolderButton.STATE_PRESSEDpublic void setRolloverIcon(Image i)
setRolloverIcon in interface SelectableIconHolderi - the iconButton.STATE_ROLLOVERpublic Image getRolloverIcon()
getRolloverIcon in interface SelectableIconHolderButton.STATE_ROLLOVERpublic void setDisabledIcon(Image i)
setDisabledIcon in interface SelectableIconHolderi - the iconpublic Image getDisabledIcon()
getDisabledIcon in interface SelectableIconHolderpublic boolean isAutoRelease()
public void setAutoRelease(boolean autoRelease)
public void setWidth(int width)
ComponentsetWidth in class Componentwidth - the width of the componentComponent.setPreferredSize(com.codename1.ui.geom.Dimension)public void setGap(int gap)
IconHoldersetGap in interface IconHoldergap - the gap in pixelspublic int getGap()
IconHoldergetGap in interface IconHolderpublic void setTextPosition(int textPosition)
setTextPosition in interface IconHoldertextPosition - alignment value (LEFT, RIGHT, BOTTOM or TOP)#LEFT,
#RIGHT,
#BOTTOM,
#TOPpublic int getTextPosition()
getTextPosition in interface IconHolder#LEFT,
#RIGHT,
#BOTTOM,
#TOPpublic void setRolloverPressedIcon(Image arg0)
setRolloverPressedIcon in interface SelectableIconHolderarg0 - icon usedpublic Image getRolloverPressedIcon()
getRolloverPressedIcon in interface SelectableIconHolderpublic Image getIconFromState()
getIconFromState in interface SelectableIconHolderpublic void setMaterialIcon(char c)
FontImage.setMaterialIcon(com.codename1.ui.Label, char)c - one of the constants from FontImagepublic void setFontIcon(Font font, char c)
com.codename1.ui.FontImage#setMaterialIcon(com.codename1.ui.Label, com.codename1.ui.Font, char)c - one of the constants from the fontpublic void setMaterialIcon(char c,
float size)
FontImage.setMaterialIcon(com.codename1.ui.Label, char, float)c - one of the constants from FontImagesize - the size of the icon in millimeterspublic void setFontIcon(Font font, char c, float size)
FontImage.setFontIcon(com.codename1.ui.Label, com.codename1.ui.Font, char, float)c - one of the constants from the fontsize - the size of the icon in millimeterspublic char getMaterialIcon()
public char getFontIcon()
public float getMaterialIconSize()
public float getFontIconSize()
public Font getIconFont()
Copyright © 2021. All rights reserved.