public class SpanButton
ImplementsActionSource<ActionEvent>, Animation, Editable, IconHolder, Iterable<Component>, SelectableIconHolder, StyleListener, 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.
Form hi = new Form("Test SpanButton", BoxLayout.y());
Image icon = FontImage.createMaterial(FontImage.MATERIAL_INFO, "Button", 3.0f);
SpanButton sb = new SpanButton("SpanButton is a composite component (lead component) that looks/acts like a Button but can break lines rather than crop them when the text is very long.");
sb.setIcon(icon);
hi.add(sb);
hi.show();
Constructors
public SpanButton() | Default constructor will be useful when adding this to the GUI builder |
public SpanButton(String txt, String textUiid) | Constructor accepting default text and uiid for the text |
public SpanButton(String txt) | Constructor accepting default text |
Methods
public void styleChanged(String propertyName, Style source) | Invoked to indicate a change in a propertyName of a Style |
protected void initUnselectedStyle(Style unselectedStyle) | Can be overridden by subclasses to perform initialization when the unselected style is set to a new value. |
public TextArea getTextComponent() | Returns the TextArea holding the actual text |
public String getTextUIID() | Returns the uiid of the actual text |
public void setTextUIID(String uiid) | Sets the UIID for the actual text |
public void setUIID(String id) | This method sets the Component the Unique identifier. |
protected void initLaf(UIManager uim) | This method initializes the Component defaults constants |
public Component getIconStyleComponent() | Gets the component used for styling font icons on this SpanLabel. |
public Style getTextAllStyles() | Returns the Style proxy object for the text of this span button. |
public Style getTextStyle() | Returns the Style object for the text of this span button. |
public String getIconUIID() | Returns the UIID for the icon |
public void setIconUIID(String uiid) | Sets the uiid for the icon if present |
public String getText() | Returns the text of the button |
public void setText(String t) | Set the text of the button |
public Image getIcon() | Returns the image of the icon |
public void setIcon(Image i) | Sets the icon for the button |
public void addLongPressListener(ActionListener l) | Binds long press listener to button events. |
public void removeLongPressListener(ActionListener l) | Unbinds long press listener to button events. |
public void addActionListener(ActionListener<ActionEvent> l) | Binds an action listener to button events |
public void removeActionListener(ActionListener<ActionEvent> l) | Removes the listener from tracking button events |
public String getIconPosition() | Returns the icon position based on border layout constraints |
public void setIconPosition(String t) | Sets the icon position based on border layout constraints |
public Command getCommand() | Returns the command instance of the button |
public void setCommand(Command cmd) | Sets the command for the component |
public String[] getPropertyNames() | A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code |
public Class[] getPropertyTypes() | Matches the property names method (see that method for further details). |
public String[] getPropertyTypeNames() | This method is here to workaround an XMLVM array type bug where property types aren’t identified properly, it returns the names of the types using the following type names: String,int,double,long,byte,short,char,String[],String[][],byte[],I… |
public Object getPropertyValue(String name) | Returns the current value of the property name, this method is used by the GUI builder |
public String setPropertyValue(String name, Object value) | Sets a new value to the given property, returns an error message if failed and null if successful. |
public 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. |
public 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. |
public Image getPressedIcon() | Returns the pressed icon of the button |
public void setPressedIcon(Image i) | Sets the pressed icon for the button |
public Image getRolloverIcon() | Returns the rollover icon of the button |
public void setRolloverIcon(Image i) | Sets the rollover icon for the button |
public Image getDisabledIcon() | Returns the disabled icon of the button |
public void setDisabledIcon(Image i) | Sets the disabled icon for the button |
public boolean isAutoRelease() | Returns if this is an auto released Button. |
public void setAutoRelease(boolean autoRelease) | Sets the auto released mode of this button, by default it’s not an auto released Button |
public void setWidth(int width) | Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
public int getGap() | Returns the gap in pixels between the icon/text to the Label boundaries |
public void setGap(int gap) | Set the gap in pixels between the icon/text to the Label boundaries |
public int getTextPosition() | Returns The position of the text relative to the icon |
public void setTextPosition(int textPosition) | Sets the position of the text relative to the icon if exists |
public Image getRolloverPressedIcon() | Indicates the icon that is displayed on the button when the button is in pressed state and is selected. |
public void setRolloverPressedIcon(Image arg0) | Indicates the icon that is displayed on the button when the button is in pressed state and is selected. |
public Image getIconFromState() | Returns the icon for the button based on its current state |
public void setFontIcon(Font font, char c) | This method is shorthand for com.codename1.ui.Font, char) |
public void setMaterialIcon(char c, float size) | This method is shorthand for char, float) |
public void setFontIcon(Font font, char c, float size) | This method is shorthand for com.codename1.ui.Font, char, float) |
public char getMaterialIcon() | Returns the material icon assigned to this component or 0 if not applicable |
public void setMaterialIcon(char c) | This method is shorthand for char) |
public char getFontIcon() | Returns the font icon assigned to this component or 0 if not applicable |
public float getMaterialIconSize() | Returns the material icon size assigned to this component or 0/-1 if not applicable |
public float getFontIconSize() | Returns the icon size assigned to this component or 0/-1 if not applicable |
public Font getIconFont() | Returns the font for the icon font or null if not font set |
Inherited fields
From Component
DEFAULT_CURSOR, CROSSHAIR_CURSOR, TEXT_CURSOR, WAIT_CURSOR, SW_RESIZE_CURSOR, SE_RESIZE_CURSOR, NW_RESIZE_CURSOR, NE_RESIZE_CURSOR, N_RESIZE_CURSOR, S_RESIZE_CURSOR, W_RESIZE_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_Y, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_IMMEDIATELY_DRAG_XY, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET, BRB_OTHER, CENTER, TOP, LEFT, BOTTOM, RIGHT, BASELINE
Inherited methods
From Container
encloseIn, encloseIn, getUIManager, setUIManager, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, keyPressed, keyReleased, getLayout, setLayout, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, addComponent, addComponent, addComponent, addComponent, replaceAndWait, replaceAndWait, replace, replaceAndWait, replace, createReplaceTransition, isEnabled, setEnabled, removeComponent, cancelRepaints, flushReplace, removeAll, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paint, paintGlass, layoutContainer, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, getComponentIndex, contains, scrollComponentToVisible, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, pointerPressed, calcPreferredSize, paramString, refreshTheme, isScrollableX, setScrollableX, isScrollableY, setScrollableY, getSideGap, getBottomGap, setScrollable, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, animateHierarchyAndWait, createAnimateHierarchy, animateHierarchy, animateHierarchyFadeAndWait, createAnimateHierarchyFade, animateHierarchyFade, animateLayoutFadeAndWait, createAnimateLayoutFadeAndWait, animateLayoutFade, createAnimateLayoutFade, animateLayoutAndWait, animateLayout, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, animateUnlayout, animateUnlayoutAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator
From Component
setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerDragged, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, pointerReleased, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, setPressedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, animate, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, laidOut, deinitialize, initComponent, isInitialized, setInitialized, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip
Constructor details
SpanButton
public SpanButton()SpanButton
public SpanButton(String txt, String textUiid)Parameters
txtString- the text
textUiidString- the new text UIID
SpanButton
public SpanButton(String txt)Method details
styleChanged
public void styleChanged(String propertyName, Style source)Invoked to indicate a change in a propertyName of a Style
NOTE By default this will trigger a call to Container#revalidate() on the parent
container, which is expensive. You can disable this behavior by calling CN.setProperty("Component.revalidateOnStyleChange", "false").
The intention is to change this behavior so that the default is to “not” revalidate on style change, so we encourage you to
set this to “false” to ensure for future compatibility.
Parameters
propertyNameString- the property name that was changed
sourceStyle- The changed Style object
initUnselectedStyle
protected void initUnselectedStyle(Style unselectedStyle)Parameters
unselectedStyleStyle- The unselected style.
getTextComponent
public TextArea getTextComponent()Returns
getTextUIID
public String getTextUIID()Returns
setTextUIID
public void setTextUIID(String uiid)Parameters
uiidString- the uiid
setUIID
public void setUIID(String id)Parameters
idString- UIID unique identifier for component type
initLaf
protected void initLaf(UIManager uim)getIconStyleComponent
public Component getIconStyleComponent()Returns
getTextAllStyles
public Style getTextAllStyles()Returns
getTextStyle
public Style getTextStyle()Returns
getIconUIID
public String getIconUIID()Returns
setIconUIID
public void setIconUIID(String uiid)Parameters
uiidString- the uiid for the icon
getText
public String getText()Returns
setText
public void setText(String t)Parameters
tString- text of the button
getIcon
public Image getIcon()Returns
setIcon
public void setIcon(Image i)Parameters
iImage- the icon
addLongPressListener
public void addLongPressListener(ActionListener l)removeLongPressListener
public void removeLongPressListener(ActionListener l)addActionListener
public void addActionListener(ActionListener<ActionEvent> l)Parameters
lActionListener<ActionEvent>- the listener
removeActionListener
public void removeActionListener(ActionListener<ActionEvent> l)Parameters
lActionListener<ActionEvent>- the listener
getIconPosition
public String getIconPosition()Returns
setIconPosition
public void setIconPosition(String t)getCommand
public Command getCommand()Returns
setCommand
public void setCommand(Command cmd)Parameters
cmdCommand- the command
getPropertyNames
public String[] getPropertyNames()Returns
getPropertyTypes
public Class[] getPropertyTypes()Returns
getPropertyTypeNames
public String[] getPropertyTypeNames()Returns
getPropertyValue
public Object getPropertyValue(String name)Parameters
nameString- the name of the property
Returns
setPropertyValue
public String setPropertyValue(String name, Object value)Parameters
nameString- the name of the property
valueObject- new value for the property
Returns
isShouldLocalize
public boolean isShouldLocalize()Returns
setShouldLocalize
public void setShouldLocalize(boolean shouldLocalize)Parameters
shouldLocalizeboolean- the shouldLocalize to set
getPressedIcon
public Image getPressedIcon()Returns
setPressedIcon
public void setPressedIcon(Image i)Parameters
iImage- the icon
getRolloverIcon
public Image getRolloverIcon()Returns
setRolloverIcon
public void setRolloverIcon(Image i)Parameters
iImage- the icon
getDisabledIcon
public Image getDisabledIcon()Returns
setDisabledIcon
public void setDisabledIcon(Image i)Parameters
iImage- the icon
isAutoRelease
public boolean isAutoRelease()Returns
setAutoRelease
public void setAutoRelease(boolean autoRelease)setWidth
public void setWidth(int width)Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly.
If a user wishes to affect the component size, setPreferredSize should be used.
Parameters
widthint- the width of the component
See also
getGap
public int getGap()Returns
setGap
public void setGap(int gap)Parameters
gapint- the gap in pixels
getTextPosition
public int getTextPosition()Returns
setTextPosition
public void setTextPosition(int textPosition)Parameters
textPositionint- alignment value (LEFT, RIGHT, BOTTOM or TOP)
getRolloverPressedIcon
public Image getRolloverPressedIcon()Returns
setRolloverPressedIcon
public void setRolloverPressedIcon(Image arg0)Parameters
arg0Image- icon used
getIconFromState
public Image getIconFromState()Returns
setFontIcon
public void setFontIcon(Font font, char c)com.codename1.ui.Font, char)Parameters
fontFont- Not documented.
cchar- one of the constants from the font
setMaterialIcon
public void setMaterialIcon(char c, float size)char, float)Parameters
cchar- one of the constants from
com.codename1.ui.FontImage sizefloat- the size of the icon in millimeters
setFontIcon
public void setFontIcon(Font font, char c, float size)com.codename1.ui.Font, char, float)Parameters
fontFont- Not documented.
cchar- one of the constants from the font
sizefloat- the size of the icon in millimeters
getMaterialIcon
public char getMaterialIcon()Returns
setMaterialIcon
public void setMaterialIcon(char c)char)Parameters
cchar- one of the constants from
com.codename1.ui.FontImage
getFontIcon
public char getFontIcon()Returns
getMaterialIconSize
public float getMaterialIconSize()Returns
getFontIconSize
public float getFontIconSize()Returns
getIconFont
public Font getIconFont()