Class SpanButton
- All Implemented Interfaces:
Animation, Editable, ActionSource<ActionEvent>, StyleListener, IconHolder, SelectableIconHolder, TextHolder, Iterable<Component>
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.
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);
-
Field Summary
Fields 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
ConstructorsConstructorDescriptionDefault constructor will be useful when adding this to the GUI builderSpanButton(String txt) Constructor accepting default textSpanButton(String txt, String textUiid) Constructor accepting default text and uiid for the text -
Method Summary
Modifier and TypeMethodDescriptionvoidBinds an action listener to button eventsvoidBinds long press listener to button events.Returns the command instance of the buttonReturns the disabled icon of the buttoncharReturns the font icon assigned to this component or 0 if not applicablefloatReturns the icon size assigned to this component or 0/-1 if not applicableintgetGap()Returns the gap in pixels between the icon/text to the Label boundariesgetIcon()Returns the image of the iconReturns the font for the icon font or null if not font setReturns the icon for the button based on its current stateReturns the icon position based on border layout constraintsGets the component used for styling font icons on this SpanLabel.Returns the UIID for the iconcharReturns the material icon assigned to this component or 0 if not applicablefloatReturns the material icon size assigned to this component or 0/-1 if not applicableReturns the pressed icon of the buttonString[]A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder codeString[]This method is here to workaround an XMLVM array type bug where property types aren't identified properly, it returns the names of the types using the following type names: String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,ListCellRendererClass[]Matches the property names method (see that method for further details).getPropertyValue(String name) Returns the current value of the property name, this method is used by the GUI builderReturns the rollover icon of the buttonIndicates the icon that is displayed on the button when the button is in pressed state and is selected.getText()Returns the text of the buttonReturns the Style proxy object for the text of this span button.Returns the TextArea holding the actual textintReturns The position of the text relative to the iconReturns the Style object for the text of this span button.Returns the uiid of the actual textprotected voidThis method initializes the Component defaults constantsprotected voidinitUnselectedStyle(Style unselectedStyle) Can be overridden by subclasses to perform initialization when the unselected style is set to a new value.booleanReturns if this is an auto released Button.booleanIndicates 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.voidRemoves the listener from tracking button eventsvoidUnbinds long press listener to button events.voidsetAutoRelease(boolean autoRelease) Sets the auto released mode of this button, by default it's not an auto released ButtonvoidsetCommand(Command cmd) Sets the command for the componentvoidSets the disabled icon for the buttonvoidsetFontIcon(Font font, char c) This method is shorthand forcom.codename1.ui.Font, char)voidsetFontIcon(Font font, char c, float size) This method is shorthand forcom.codename1.ui.Font, char, float)voidsetGap(int gap) Set the gap in pixels between the icon/text to the Label boundariesvoidSets the icon for the buttonvoidSets the icon position based on border layout constraintsvoidsetIconUIID(String uiid) Sets the uiid for the icon if presentvoidsetMaterialIcon(char c) This method is shorthand forchar)voidsetMaterialIcon(char c, float size) This method is shorthand forchar, float)voidSets the pressed icon for the buttonsetPropertyValue(String name, Object value) Sets a new value to the given property, returns an error message if failed and null if successful.voidSets the rollover icon for the buttonvoidsetRolloverPressedIcon(Image arg0) Indicates the icon that is displayed on the button when the button is in pressed state and is selected.voidsetShouldLocalize(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.voidSet the text of the buttonvoidsetTextPosition(int textPosition) Sets the position of the text relative to the icon if existsvoidsetTextUIID(String uiid) Sets the UIID for the actual textvoidThis method sets the Component the Unique identifier.voidsetWidth(int width) Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly.voidstyleChanged(String propertyName, Style source) Invoked to indicate a change in a propertyName of a StyleMethods inherited from class Container
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, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isScrollableX, isScrollableY, isSelectableInteraction, isSurface, 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, updateTabIndicesMethods inherited from class Component
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, animate, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, 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, initDisabledStyle, initPressedStyle, initSelectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyRepeated, laidOut, 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, 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, setAccessibilityText, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, 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, setPinchBlocksDragAndDrop, 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, setUIIDFinal, setUnselectedStyle, setVisible, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContainsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
SpanButton
public SpanButton()Default constructor will be useful when adding this to the GUI builder -
SpanButton
-
SpanButton
Constructor accepting default text
-
-
Method Details
-
styleChanged
Description copied from class:ComponentInvoked to indicate a change in a propertyName of a Style
NOTE By default this will trigger a call to
Container#revalidate()on the parent container, which is expensive. You can disable this behavior by callingCN.setProperty("Component.revalidateOnStyleChange", "false"). The intention is to change this behavior so that the default is to "not" revalidate on style change, so we encourage you to set this to "false" to ensure for future compatibility.Parameters
-
propertyName: the property name that was changed -
source: The changed Style object
- Specified by:
styleChangedin interfaceStyleListener- Overrides:
styleChangedin classComponent
-
-
initUnselectedStyle
Description copied from class:ComponentCan be overridden by subclasses to perform initialization when the unselected style is set to a new value.
Parameters
unselectedStyle: The unselected style.
Since
8.0
- Overrides:
initUnselectedStylein classComponent
-
getTextComponent
Returns the TextArea holding the actual text
Returns
the component
-
getTextUIID
Returns the uiid of the actual text
Returns
the uiid
-
setTextUIID
Sets the UIID for the actual text
Parameters
uiid: the uiid
-
setUIID
-
initLaf
-
getIconStyleComponent
Gets the component used for styling font icons on this SpanLabel.
Returns
The component used for styling font icons on this SpanLabel.
Since
7.0
- Specified by:
getIconStyleComponentin interfaceIconHolder
-
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
Returns the Style object for the text of this span button.
Returns
The Style object for the text of this span button.
-
getIconUIID
Returns the UIID for the icon
Returns
the uiid
- Specified by:
getIconUIIDin interfaceIconHolder
-
setIconUIID
Sets the uiid for the icon if present
Parameters
uiid: the uiid for the icon
- Specified by:
setIconUIIDin interfaceIconHolder
-
getText
Returns the text of the button
Returns
the text
- Specified by:
getTextin interfaceTextHolder
-
setText
Set the text of the button
Parameters
t: text of the button
- Specified by:
setTextin interfaceTextHolder
-
getIcon
Returns the image of the icon
Returns
the icon
- Specified by:
getIconin interfaceIconHolder
-
setIcon
Sets the icon for the button
Parameters
i: the icon
- Specified by:
setIconin interfaceIconHolder
-
addLongPressListener
Binds long press listener to button events.
Parameters
l
Since
7.0
- Overrides:
addLongPressListenerin classComponent
-
removeLongPressListener
Unbinds long press listener to button events.
Parameters
l
Since
7.0
- Overrides:
removeLongPressListenerin classComponent
-
addActionListener
Binds an action listener to button events
Parameters
l: the listener
- Specified by:
addActionListenerin interfaceActionSource<ActionEvent>
-
removeActionListener
Removes the listener from tracking button events
Parameters
l: the listener
- Specified by:
removeActionListenerin interfaceActionSource<ActionEvent>
-
getIconPosition
Returns the icon position based on border layout constraints
Returns
position either North/South/East/West
-
setIconPosition
Sets the icon position based on border layout constraints
Parameters
s: position either North/South/East/West
-
getCommand
Returns the command instance of the button
Returns
the command instance of the button
-
setCommand
Sets the command for the component
Parameters
cmd: the command
-
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
- Overrides:
getPropertyNamesin classComponent
-
getPropertyTypes
Matches the property names method (see that method for further details).
Returns
the types of the properties
- Overrides:
getPropertyTypesin classComponent
-
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
- Overrides:
getPropertyTypeNamesin classComponent
-
getPropertyValue
Returns the current value of the property name, this method is used by the GUI builder
Parameters
name: the name of the property
Returns
the value of said property
- Overrides:
getPropertyValuein classComponent
-
setPropertyValue
Sets a new value to the given property, returns an error message if failed and null if successful. Notice that some builtin properties such as "$designMode" might be sent to components to indicate application state.
Parameters
-
name: the name of the property -
value: new value for the property
Returns
error message or null
- Overrides:
setPropertyValuein classComponent
-
-
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: the shouldLocalize to set
-
getPressedIcon
Returns the pressed icon of the button
Returns
the pressed icon
- Specified by:
getPressedIconin interfaceSelectableIconHolder
-
setPressedIcon
Sets the pressed icon for the button
Parameters
i: the icon
- Specified by:
setPressedIconin interfaceSelectableIconHolder
-
getRolloverIcon
Returns the rollover icon of the button
Returns
the pressed icon
- Specified by:
getRolloverIconin interfaceSelectableIconHolder
-
setRolloverIcon
Sets the rollover icon for the button
Parameters
i: the icon
- Specified by:
setRolloverIconin interfaceSelectableIconHolder
-
getDisabledIcon
Returns the disabled icon of the button
Returns
the pressed icon
- Specified by:
getDisabledIconin interfaceSelectableIconHolder
-
setDisabledIcon
Sets the disabled icon for the button
Parameters
i: the icon
- Specified by:
setDisabledIconin interfaceSelectableIconHolder
-
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) Description copied from class:ComponentSets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly.
If a user wishes to affect the component size, setPreferredSize should be used.
Parameters
width: the width of the component
See also
- #setPreferredSize
-
getGap
public int getGap()Description copied from interface:IconHolderReturns 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
- Specified by:
getGapin interfaceIconHolder
-
setGap
public void setGap(int gap) Description copied from interface:IconHolderSet the gap in pixels between the icon/text to the Label boundaries
Parameters
gap: the gap in pixels
- Specified by:
setGapin interfaceIconHolder
-
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
See also
-
#LEFT
-
#RIGHT
-
#BOTTOM
-
#TOP
- Specified by:
getTextPositionin interfaceIconHolder
-
-
setTextPosition
public void setTextPosition(int textPosition) Sets the position of the text relative to the icon if exists
Parameters
textPosition: alignment value (LEFT, RIGHT, BOTTOM or TOP)
See also
-
#LEFT
-
#RIGHT
-
#BOTTOM
-
#TOP
- Specified by:
setTextPositionin interfaceIconHolder
-
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
Since
7.0
- 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
Since
7.0
- Specified by:
setRolloverPressedIconin interfaceSelectableIconHolder
-
getIconFromState
Returns the icon for the button based on its current state
Returns
the button icon based on its current state
Since
7.0
- Specified by:
getIconFromStatein interfaceSelectableIconHolder
-
setFontIcon
This method is shorthand for
com.codename1.ui.Font, char)Parameters
c: one of the constants from the font
-
setMaterialIcon
public void setMaterialIcon(char c, float size) This method is shorthand for
char, float)Parameters
-
c: one of the constants fromcom.codename1.ui.FontImage -
size: the size of the icon in millimeters
- Specified by:
setMaterialIconin interfaceIconHolder
-
-
setFontIcon
This method is shorthand for
com.codename1.ui.Font, char, float)Parameters
-
c: one of the constants from the font -
size: the size of the icon in millimeters
- Specified by:
setFontIconin interfaceIconHolder
-
-
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: one of the constants fromcom.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
Returns the font for the icon font or null if not font set
Returns
the material icon size
-