public class Label extends Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, 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.
|
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content.
|
int |
getAlignment()
Returns the alignment of the Label
|
int |
getBaselineResizeBehavior()
Returns a constant indicating how the baseline varies with the size
of the component.
|
int |
getGap()
Returns the gap in pixels between the icon/text to the Label boundaries
|
Image |
getIcon()
Returns the labels icon
|
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.
|
boolean |
isEndsWith3Points()
Simple getter
|
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)
Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
|
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 |
setShiftText(int shiftText)
This method shifts the text from it's position in pixels.
|
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(long delay,
boolean rightToLeft)
This method will start the text ticker
|
void |
stopTicker()
Stops the text ticker
|
addFocusListener, calcScrollSize, contains, deinitialize, deinitializeCustomStyle, dragInitiated, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBorder, getBottomGap, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getHeight, getLabelForComponent, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getScrollAnimationSpeed, getScrollDimension, getScrollX, getScrollY, getSelectCommandText, getSelectedStyle, getSideGap, getStyle, getUIID, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, handlesInput, hasFocus, initComponent, initCustomStyle, isBorderPainted, isDragActivated, isEnabled, isFocusable, isFocusPainted, isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyPressed, keyReleased, keyRepeated, laidOut, longKeyPress, longPointerPress, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerDragged, pointerHover, pointerHoverReleased, pointerPressed, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setBorderPainted, setCellRenderer, setDirtyRegion, setEnabled, setFocus, setFocusable, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setLabelForComponent, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setRTL, setScrollAnimationSpeed, setScrollSize, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setStyle, setTactileTouch, setTensileDragEnabled, setUIID, setUnselectedStyle, setUnSelectedStyle, setVisible, setWidth, setX, setY, 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 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(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()