public class SpanButton

  1. Object
  2. Component
  3. Container
  4. 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

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()
Default constructor will be useful when adding this to the GUI builder

SpanButton

public SpanButton(String txt, String textUiid)
Constructor accepting default text and uiid for the text

Parameters

txt String
the text
textUiid String
the new text UIID

SpanButton

public SpanButton(String txt)
Constructor accepting default text

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

propertyName String
the property name that was changed
source Style
The changed Style object

initUnselectedStyle

protected void initUnselectedStyle(Style unselectedStyle)
Can be overridden by subclasses to perform initialization when the unselected style is set to a new value.

Parameters

unselectedStyle Style
The unselected style.

getTextComponent

public TextArea getTextComponent()
Returns the TextArea holding the actual text

Returns

the component

getTextUIID

public String getTextUIID()
Returns the uiid of the actual text

Returns

the uiid

setTextUIID

public void setTextUIID(String uiid)
Sets the UIID for the actual text

Parameters

uiid String
the uiid

setUIID

public void setUIID(String id)
This method sets the Component the Unique identifier. This method should be used before a component has been initialized

Parameters

id String
UIID unique identifier for component type

initLaf

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

getIconStyleComponent

public Component getIconStyleComponent()
Gets the component used for styling font icons on this SpanLabel.

Returns

The component used for styling font icons on this SpanLabel.

getTextAllStyles

public Style getTextAllStyles()
Returns the Style proxy object for the text of this span button.

Returns

The Style object for the text of this span button.

getTextStyle

public Style getTextStyle()
Returns the Style object for the text of this span button.

Returns

The Style object for the text of this span button.

getIconUIID

public String getIconUIID()
Returns the UIID for the icon

Returns

the uiid

setIconUIID

public void setIconUIID(String uiid)
Sets the uiid for the icon if present

Parameters

uiid String
the uiid for the icon

getText

public String getText()
Returns the text of the button

Returns

the text

setText

public void setText(String t)
Set the text of the button

Parameters

t String
text of the button

getIcon

public Image getIcon()
Returns the image of the icon

Returns

the icon

setIcon

public void setIcon(Image i)
Sets the icon for the button

Parameters

i Image
the icon

addLongPressListener

public void addLongPressListener(ActionListener l)
Binds long press listener to button events.

removeLongPressListener

public void removeLongPressListener(ActionListener l)
Unbinds long press listener to button events.

addActionListener

public void addActionListener(ActionListener<ActionEvent> l)
Binds an action listener to button events

Parameters

l ActionListener<ActionEvent>
the listener

removeActionListener

public void removeActionListener(ActionListener<ActionEvent> l)
Removes the listener from tracking button events

Parameters

l ActionListener<ActionEvent>
the listener

getIconPosition

public String getIconPosition()
Returns the icon position based on border layout constraints

Returns

position either North/South/East/West

setIconPosition

public void setIconPosition(String t)
Sets the icon position based on border layout constraints

getCommand

public Command getCommand()
Returns the command instance of the button

Returns

the command instance of the button

setCommand

public void setCommand(Command cmd)
Sets the command for the component

Parameters

cmd Command
the command

getPropertyNames

public String[] getPropertyNames()
A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code

Returns

the property names allowing mutation

getPropertyTypes

public Class[] getPropertyTypes()
Matches the property names method (see that method for further details).

Returns

the types of the properties

getPropertyTypeNames

public String[] getPropertyTypeNames()
This method is here to workaround an XMLVM array type bug where property types aren’t identified properly, it returns the names of the types using the following type names: String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,ListCellRenderer

Returns

Array of type names

getPropertyValue

public Object getPropertyValue(String name)
Returns the current value of the property name, this method is used by the GUI builder

Parameters

name String
the name of the property

Returns

the value of said property

setPropertyValue

public String setPropertyValue(String name, Object value)
Sets a new value to the given property, returns an error message if failed and null if successful. Notice that some builtin properties such as “$designMode” might be sent to components to indicate application state.

Parameters

name String
the name of the property
value Object
new value for the property

Returns

error message or null

isShouldLocalize

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.

Returns

the shouldLocalize value

setShouldLocalize

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.

Parameters

shouldLocalize boolean
the shouldLocalize to set

getPressedIcon

public Image getPressedIcon()
Returns the pressed icon of the button

Returns

the pressed icon

setPressedIcon

public void setPressedIcon(Image i)
Sets the pressed icon for the button

Parameters

i Image
the icon

getRolloverIcon

public Image getRolloverIcon()
Returns the rollover icon of the button

Returns

the pressed icon

setRolloverIcon

public void setRolloverIcon(Image i)
Sets the rollover icon for the button

Parameters

i Image
the icon

getDisabledIcon

public Image getDisabledIcon()
Returns the disabled icon of the button

Returns

the pressed icon

setDisabledIcon

public void setDisabledIcon(Image i)
Sets the disabled icon for the button

Parameters

i Image
the icon

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.

setAutoRelease

public void setAutoRelease(boolean autoRelease)
Sets the auto released mode of this button, by default it’s not an auto released Button

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 int
the width of the component

getGap

public int getGap()
Returns the gap in pixels between the icon/text to the Label boundaries

Returns

the gap in pixels between the icon/text to the Label boundaries

setGap

public void setGap(int gap)
Set the gap in pixels between the icon/text to the Label boundaries

Parameters

gap int
the gap in pixels

getTextPosition

public int getTextPosition()
Returns The position of the text relative to the icon

Returns

The position of the text relative to the icon, one of: LEFT, RIGHT, BOTTOM, TOP

setTextPosition

public void setTextPosition(int textPosition)
Sets the position of the text relative to the icon if exists

Parameters

textPosition int
alignment value (LEFT, RIGHT, BOTTOM or TOP)

getRolloverPressedIcon

public Image 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

setRolloverPressedIcon

public void setRolloverPressedIcon(Image arg0)
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

arg0 Image
icon used

getIconFromState

public Image getIconFromState()
Returns the icon for the button based on its current state

Returns

the button icon based on its current state

setFontIcon

public void setFontIcon(Font font, char c)
This method is shorthand for com.codename1.ui.Font, char)

Parameters

font Font
Not documented.
c char
one of the constants from the font

setMaterialIcon

public void setMaterialIcon(char c, float size)
This method is shorthand for char, float)

Parameters

c char
one of the constants from com.codename1.ui.FontImage
size float
the size of the icon in millimeters

setFontIcon

public void setFontIcon(Font font, char c, float size)
This method is shorthand for com.codename1.ui.Font, char, float)

Parameters

font Font
Not documented.
c char
one of the constants from the font
size float
the size of the icon in millimeters

getMaterialIcon

public char getMaterialIcon()
Returns the material icon assigned to this component or 0 if not applicable

Returns

the material icon

setMaterialIcon

public void setMaterialIcon(char c)
This method is shorthand for char)

Parameters

c char
one of the constants from com.codename1.ui.FontImage

getFontIcon

public char getFontIcon()
Returns the font icon assigned to this component or 0 if not applicable

Returns

the material icon

getMaterialIconSize

public float getMaterialIconSize()
Returns the material icon size assigned to this component or 0/-1 if not applicable

Returns

the material icon size

getFontIconSize

public float getFontIconSize()
Returns the icon size assigned to this component or 0/-1 if not applicable

Returns

the icon size

getIconFont

public Font getIconFont()
Returns the font for the icon font or null if not font set

Returns

the material icon size