public class Label extends Component
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, 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, LEFT, RIGHT, TOP
Constructor and Description |
---|
Label()
Construct an empty label
|
Label(Image icon)
Constructs a new label with the specified icon
|
Label(String text)
Constructs a new label with the specified string of text, left justified.
|
Modifier and Type | Method and Description |
---|---|
boolean |
animate()
Allows the animation to reduce "repaint" calls when it returns false.
|
void |
bindProperty(String prop,
BindTarget target)
Binds the given property name to the given bind target
|
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content.
|
int |
getAlignment()
Deprecated.
use Style.getAlignment instead
|
int |
getBaseline(int width,
int height)
The baseline for the component text according to which it should be aligned
with other components for best visual look.
|
int |
getBaselineResizeBehavior()
Returns a constant indicating how the baseline varies with the size
of the component.
|
String[] |
getBindablePropertyNames()
Returns the names of the properties within this component that can be bound for persistence,
the order of these names mean that the first one will be the first bound
|
Class[] |
getBindablePropertyTypes()
Returns the types of the properties that are bindable within this component
|
Object |
getBoundPropertyValue(String prop)
Allows the binding code to extract the value of the property
|
int |
getGap()
Returns the gap in pixels between the icon/text to the Label boundaries
|
Image |
getIcon()
Returns the labels icon
|
Object |
getMask()
Returns the mask matching the given image
|
Image |
getMaskedIcon()
If a mask is applied returns the icon with a mask, otherwise returns the icon
|
String |
getMaskName()
Determines the name of the mask from the image constants thus allowing the mask to be applied from the theme
|
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
|
int |
getShiftMillimeters()
Returns the number of millimeters that should be shifted in tickering
|
int |
getShiftText()
Simple getter to return how many pixels to shift the text inside the Label
|
String |
getText()
Returns the label text
|
int |
getTextPosition()
Returns The position of the text relative to the icon
|
int |
getVerticalAlignment()
Returns the vertical alignment of the Label, this will only work when the icon
is in the side of the text and not above or bellow it.
|
static boolean |
isDefaultTickerEnabled()
Allows disabling/enabling tickers globally
|
boolean |
isEndsWith3Points()
Simple getter
|
boolean |
isShouldLocalize()
Indicates if text should be localized when set to the label, by default
all text is localized so this allows disabling automatic localization for
a specific label.
|
boolean |
isTickerEnabled()
This method return true if the ticker is enabled on this Label
|
boolean |
isTickerRunning()
Returns true if the ticker is running
|
void |
paint(Graphics g)
This method paints the Component on the screen, it should be overriden
by subclasses to perform custom drawing or invoke the UI API's to let
the PLAF perform the rendering.
|
protected String |
paramString()
Returns a string representing the state of this component.
|
void |
setAlignment(int align)
Deprecated.
use Style.setAlignment instead
|
void |
setBoundPropertyValue(String prop,
Object value)
Sets the value of a bound property within this component, notice that this method MUST NOT fire
the property change event when invoked to prevent recursion!
|
static void |
setDefaultTickerEnabled(boolean aDefaultTickerEnabled)
Allows disabling/enabling tickers globally
|
void |
setEndsWith3Points(boolean endsWith3Points)
If the Label text is too long fit the text to the widget and add "..."
points at the end.
|
void |
setGap(int gap)
Set the gap in pixels between the icon/text to the Label boundaries
|
void |
setIcon(Image icon)
Sets the Label icon, if the icon is unmodified a repaint would not be triggered
|
void |
setMask(Object mask)
A mask image can be applied to the label (see the image mask method for details)
which allows for things like rounded image appearance etc.
|
void |
setMaskName(String maskName)
Determines the name of the mask from the image constants thus allowing the mask to be applied from the theme
|
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 |
setShiftMillimeters(int shiftMillimeters)
Sets the millimeters that should be shifted in tickering
|
void |
setShiftText(int shiftText)
This method shifts the text from it's position in pixels.
|
void |
setShouldLocalize(boolean shouldLocalize)
Indicates if text should be localized when set to the label, by default
all text is localized so this allows disabling automatic localization for
a specific label.
|
void |
setText(String text)
Sets the Label text
|
void |
setTextPosition(int textPosition)
Sets the position of the text relative to the icon if exists
|
void |
setTickerEnabled(boolean tickerEnabled)
Sets the Label to allow ticking of the text.
|
void |
setVerticalAlignment(int valign)
Sets the vertical alignment of the Label to one of: CENTER, TOP, BOTTOM
|
boolean |
shouldTickerStart()
Returns true if a ticker should be started since there is no room to show
the text in the label.
|
void |
startTicker()
This method will start the text ticker
|
void |
startTicker(long delay,
boolean rightToLeft)
This method will start the text ticker
|
void |
stopTicker()
Stops the text ticker
|
void |
unbindProperty(String prop,
BindTarget target)
Removes a bind target from the given property name
|
addDragOverListener, addDropListener, addFocusListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, calcScrollSize, cancelRepaints, clearClientProperties, contains, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, dragInitiated, drawDraggedImage, drop, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBorder, getBottomGap, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus, initComponent, initCustomStyle, initLaf, installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyPressed, keyReleased, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, refreshTheme, removeDragOverListener, removeDropListener, removeFocusListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, repaint, repaint, requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged, toString
public Label(String text)
text
- the string that the label presents.public Label()
public Label(Image icon)
icon
- the image that the label presents.public int getBaselineResizeBehavior()
Component
getBaselineResizeBehavior
in class Component
public int getBaseline(int width, int height)
Component
getBaseline
in class Component
width
- the component widthheight
- the component heightpublic void setText(String text)
text
- the string that the label presents.public String getText()
public void setIcon(Image icon)
icon
- the image that the label presents.public Image getIcon()
public void setAlignment(int align)
align
- alignment valueComponent.CENTER
,
Component.LEFT
,
Component.RIGHT
public void setVerticalAlignment(int valign)
valign
- alignment valueComponent.CENTER
,
Component.TOP
,
Component.BOTTOM
public int getVerticalAlignment()
Component.CENTER
,
Component.TOP
,
Component.BOTTOM
public int getAlignment()
Component.CENTER
,
Component.LEFT
,
Component.RIGHT
public void setTextPosition(int textPosition)
textPosition
- alignment value (LEFT, RIGHT, BOTTOM or TOP)Component.LEFT
,
Component.RIGHT
,
Component.BOTTOM
,
Component.TOP
public int getTextPosition()
Component.LEFT
,
Component.RIGHT
,
Component.BOTTOM
,
Component.TOP
public void setGap(int gap)
gap
- the gap in pixelspublic int getGap()
protected String paramString()
Component
null
.paramString
in class Component
public void paint(Graphics g)
Component
protected Dimension calcPreferredSize()
Component
calcPreferredSize
in class Component
public int getShiftText()
public void setShiftText(int shiftText)
shiftText
- The number of pixels to move the textpublic boolean shouldTickerStart()
public void startTicker()
public void startTicker(long delay, boolean rightToLeft)
delay
- the delay in millisecods between animation intervalsrightToLeft
- if true move the text to the leftpublic void stopTicker()
public boolean isTickerRunning()
public void setTickerEnabled(boolean tickerEnabled)
tickerEnabled
- public boolean isTickerEnabled()
public void setEndsWith3Points(boolean endsWith3Points)
endsWith3Points
- true if text should add "..." at the endpublic boolean isEndsWith3Points()
public boolean animate()
Animation
Display
class.public static boolean isDefaultTickerEnabled()
public static void setDefaultTickerEnabled(boolean aDefaultTickerEnabled)
aDefaultTickerEnabled
- the defaultTickerEnabled to setpublic void setMask(Object mask)
mask
- the mask returned from the image objectpublic Object getMask()
public String getMaskName()
public void setMaskName(String maskName)
maskName
- the maskName to setpublic String[] getPropertyNames()
Component
getPropertyNames
in class Component
public Class[] getPropertyTypes()
Component
getPropertyTypes
in class Component
public String[] getPropertyTypeNames()
Component
getPropertyTypeNames
in class Component
public Object getPropertyValue(String name)
Component
getPropertyValue
in class Component
name
- the name of the propertypublic String setPropertyValue(String name, Object value)
Component
setPropertyValue
in class Component
name
- the name of the propertyvalue
- new value for the propertypublic Image getMaskedIcon()
public String[] getBindablePropertyNames()
Component
getBindablePropertyNames
in class Component
public Class[] getBindablePropertyTypes()
Component
getBindablePropertyTypes
in class Component
public void bindProperty(String prop, BindTarget target)
Component
bindProperty
in class Component
prop
- the property nametarget
- the target binderpublic void unbindProperty(String prop, BindTarget target)
Component
unbindProperty
in class Component
prop
- the property namestarget
- the target binderpublic Object getBoundPropertyValue(String prop)
Component
getBoundPropertyValue
in class Component
prop
- the propertypublic void setBoundPropertyValue(String prop, Object value)
Component
setBoundPropertyValue
in class Component
prop
- the property whose value should be setvalue
- the valuepublic boolean isShouldLocalize()
public void setShouldLocalize(boolean shouldLocalize)
shouldLocalize
- the shouldLocalize to setpublic int getShiftMillimeters()
public void setShiftMillimeters(int shiftMillimeters)
shiftMillimeters
- the shiftMillimeters to set