public class SpanLabel
ImplementsAnimation, Editable, IconHolder, Iterable<Component>, StyleListener, TextHolder
A multi line label component that can be easily localized, this is simply based on a text area combined with a label.
Form hi = new Form("Test SpanLabel", BoxLayout.y());
Image icon = FontImage.createMaterial(FontImage.MATERIAL_INFO, "Label", 3.0f);
SpanLabel d = new SpanLabel("Default SpanLabel that can seamlessly line break when the text is really long.");
d.setIcon(icon);
SpanLabel l = new SpanLabel("NORTH Positioned Icon SpanLabel that can seamlessly line break when the text is really long.");
l.setIcon(icon);
l.setIconPosition(BorderLayout.NORTH);
SpanLabel r = new SpanLabel("SOUTH Positioned Icon SpanLabel that can seamlessly line break when the text is really long.");
r.setIcon(icon);
r.setIconPosition(BorderLayout.SOUTH);
SpanLabel c = new SpanLabel("EAST Positioned Icon SpanLabel that can seamlessly line break when the text is really long.");
c.setIcon(icon);
c.setIconPosition(BorderLayout.EAST);
hi.add(d).add(l).add(r).add(c);
hi.show();
Constructors
public SpanLabel() | Default constructor will be useful when adding this to the GUI builder |
public SpanLabel(String txt, String textUiid) | Constructor accepting default text and uiid for the text |
public SpanLabel(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. |
protected void initLaf(UIManager uim) | This method initializes the Component defaults constants |
public int getPreferredW() | Helper method to retrieve the preferred width of the component. |
public void setPreferredW(int preferredW) | Helper method to set the preferred width of the component. |
protected Dimension calcPreferredSize() | Calculates the preferred size based on component content. |
public Component getIconStyleComponent() | Gets the component used for styling font icons on this SpanLabel. |
public TextArea getTextComponent() | Returns the TextArea holding the actual text |
public void setUIID(String id) | This method sets the Component the Unique identifier. |
public String getTextUIID() | Returns the uiid of the actual text |
public void setTextUIID(String uiid) | Sets the UIID for the actual text |
public Style getTextAllStyles() | Returns the Style proxy object for the text of this span button. |
public Style getTextUnselectedStyle() | Returns the text elements style object |
public void setTextUnselectedStyle(Style t) | The text elements style object |
public Style getTextSelectedStyle() | Returns the text elements style object |
public void setTextSelectedStyle(Style t) | The text elements style object |
public String getIconUIID() | Returns the UIID for the icon |
public void setIconUIID(String uiid) | Sets the uiid for the icon if present |
public int getIconValign() | Gets the vertical alignment of the icon with respect to the text of the span label. |
public void setIconValign(int align) | Sets the vertical alignment of the icon with respect to the text of the span label. |
public String getText() | Returns the text of the label |
public void setText(String t) | Set the text of the label |
public int getTextBlockAlign() | Returns the alignment of the whole text block and not the text within it! |
public void setTextBlockAlign(int align) | Indicates the alignment of the whole text block, this is different from setting the alignment of the text within the block since the UIID might have a border or other design element that won’t be affected by such alignment. |
public Image getIcon() | Returns the image of the icon |
public void setIcon(Image i) | Sets the icon for the label |
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 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 boolean isTextSelectionEnabled() | Checks if text selection is enabled on this SpanLabel. |
public void setTextSelectionEnabled(boolean enabled) | Enables or disables text selection on this span label. |
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 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, 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, 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, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, 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
SpanLabel
public SpanLabel()SpanLabel
public SpanLabel(String txt, String textUiid)Parameters
txtString- the text
textUiidString- the new text UIID
SpanLabel
public SpanLabel(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.
initLaf
protected void initLaf(UIManager uim)getPreferredW
public int getPreferredW()Returns
setPreferredW
public void setPreferredW(int preferredW)Parameters
preferredWint- the preferred width of the component
calcPreferredSize
protected Dimension calcPreferredSize()Returns
getIconStyleComponent
public Component getIconStyleComponent()Returns
getTextComponent
public TextArea getTextComponent()Returns
setUIID
public void setUIID(String id)Parameters
idString- UIID unique identifier for component type
getTextUIID
public String getTextUIID()Returns
setTextUIID
public void setTextUIID(String uiid)Parameters
uiidString- the uiid
getTextAllStyles
public Style getTextAllStyles()Returns
getTextUnselectedStyle
public Style getTextUnselectedStyle()Returns
setTextUnselectedStyle
public void setTextUnselectedStyle(Style t)Parameters
tStyle- the style object
getTextSelectedStyle
public Style getTextSelectedStyle()Returns
setTextSelectedStyle
public void setTextSelectedStyle(Style t)Parameters
tStyle- the style object
getIconUIID
public String getIconUIID()Returns
setIconUIID
public void setIconUIID(String uiid)Parameters
uiidString- the uiid for the icon
getIconValign
public int getIconValign()Returns
#TOP, #BOTTOM, or #CENTER.setIconValign
public void setIconValign(int align)#CENTERParameters
alignint- One of
#TOP,#BOTTOM, or#CENTER.
getText
public String getText()Returns
setText
public void setText(String t)Parameters
tString- text of the label
getTextBlockAlign
public int getTextBlockAlign()Returns
setTextBlockAlign
public void setTextBlockAlign(int align)Parameters
alignint- valid values are Component.LEFT, Component.RIGHT, Component.CENTER. Anything else will stretch the text block
getIcon
public Image getIcon()Returns
setIcon
public void setIcon(Image i)Parameters
iImage- the icon
getIconPosition
public String getIconPosition()Returns
setIconPosition
public void setIconPosition(String t)Parameters
tString- position either North/South/East/West
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
isTextSelectionEnabled
public boolean isTextSelectionEnabled()Returns
setTextSelectionEnabled
public void setTextSelectionEnabled(boolean enabled)Parameters
enabledboolean- True to enable text selection on this label.
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
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)
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()