com.sun.lwuit
Class Label

java.lang.Object
  extended by com.sun.lwuit.Component
      extended by com.sun.lwuit.Label
Direct Known Subclasses:
Button, DefaultListCellRenderer, Slider

public class Label
extends Component

Allows displaying labels and images with different alignment options, this class is a base class for several components allowing them to declare alignement/icon look in a similar way.

Author:
Chen Fishbein

Field Summary
 
Fields inherited from class com.sun.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Constructor Summary
Label()
          Construct an empty label
Label(Image icon)
          Constructs a new label with the specified icon
Label(java.lang.String text)
          Constructs a new label with the specified string of text, left justified.
 
Method Summary
 boolean animate()
           
 int getAlignment()
          Deprecated. use Style.getAlignment instead
 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
 java.lang.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.
 void setAlignment(int align)
          Deprecated. use Style.setAlignment instead
 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 setSize(Dimension d)
          Sets the Component size, this method is exposed for the purpose of external layout managers and should not be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.
 void setText(java.lang.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
 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 effect the component size setPreferredSize should be used.
 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
 
Methods inherited from class com.sun.lwuit.Component
addFocusListener, contains, drop, getAbsoluteX, getAbsoluteY, getBaseline, getBottomGap, getClientProperty, getComponentForm, getDirtyRegion, getDisabledStyle, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypes, getPropertyValue, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getStyle, getTensileLength, getUIID, getUnselectedStyle, getWidth, getX, getY, growShrink, handlesInput, hasFocus, isAlwaysTensile, isDraggable, isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isRTL, isScrollableX, isScrollableY, isScrollVisible, isSmoothScrolling, isSnapToGrid, isTactileTouch, isTensileDragEnabled, isVisible, keyPressed, keyReleased, keyRepeated, paintBackgrounds, paintComponent, paintComponent, paintLock, paintLockRelease, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, setAlwaysTensile, setCellRenderer, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setPropertyValue, setRTL, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setVisible, setX, setY, styleChanged, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Label

public Label(java.lang.String text)
Constructs a new label with the specified string of text, left justified.

Parameters:
text - the string that the label presents.

Label

public Label()
Construct an empty label


Label

public Label(Image icon)
Constructs a new label with the specified icon

Parameters:
icon - the image that the label presents.
Method Detail

getBaselineResizeBehavior

public int getBaselineResizeBehavior()
Description copied from class: Component
Returns a constant indicating how the baseline varies with the size of the component.

Overrides:
getBaselineResizeBehavior in class Component
Returns:
one of BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET or BRB_OTHER

setText

public void setText(java.lang.String text)
Sets the Label text

Parameters:
text - the string that the label presents.

getText

public java.lang.String getText()
Returns the label text

Returns:
the label text

setIcon

public void setIcon(Image icon)
Sets the Label icon, if the icon is unmodified a repaint would not be triggered

Parameters:
icon - the image that the label presents.

getIcon

public Image getIcon()
Returns the labels icon

Returns:
the labels icon

setAlignment

public void setAlignment(int align)
Deprecated. use Style.setAlignment instead

Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT

Parameters:
align - alignment value
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT

setVerticalAlignment

public void setVerticalAlignment(int valign)
Sets the vertical alignment of the Label to one of: CENTER, TOP, BOTTOM

Parameters:
valign - alignment value
See Also:
Component.CENTER, Component.TOP, Component.BOTTOM

getVerticalAlignment

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

Returns:
the vertical alignment of the Label one of: CENTER, TOP, BOTTOM
See Also:
Component.CENTER, Component.TOP, Component.BOTTOM

getAlignment

public int getAlignment()
Deprecated. use Style.getAlignment instead

Returns the alignment of the Label

Returns:
the alignment of the Label one of: CENTER, LEFT, RIGHT
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT

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:
Component.LEFT, Component.RIGHT, Component.BOTTOM, Component.TOP

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:
Component.LEFT, Component.RIGHT, Component.BOTTOM, Component.TOP

setGap

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

Parameters:
gap - the gap in pixels

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

paint

public void paint(Graphics g)
Description copied from class: Component
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.

Overrides:
paint in class Component
Parameters:
g - the component graphics

getShiftText

public int getShiftText()
Simple getter to return how many pixels to shift the text inside the Label

Returns:
number of pixels to shift

setShiftText

public void setShiftText(int shiftText)
This method shifts the text from it's position in pixels. The value can be positive/negative to move the text to the right/left

Parameters:
shiftText - The number of pixels to move the text

shouldTickerStart

public boolean shouldTickerStart()
Returns true if a ticker should be started since there is no room to show the text in the label.

Returns:
true if a ticker should start running

startTicker

public void startTicker()
This method will start the text ticker


startTicker

public void startTicker(long delay,
                        boolean rightToLeft)
This method will start the text ticker

Parameters:
delay - the delay in millisecods between animation intervals
rightToLeft - if true move the text to the left

stopTicker

public void stopTicker()
Stops the text ticker


isTickerRunning

public boolean isTickerRunning()
Returns true if the ticker is running

Returns:
true if the ticker is running

setTickerEnabled

public void setTickerEnabled(boolean tickerEnabled)
Sets the Label to allow ticking of the text. By default is true

Parameters:
tickerEnabled -

isTickerEnabled

public boolean isTickerEnabled()
This method return true if the ticker is enabled on this Label

Returns:
tickerEnabled

setEndsWith3Points

public void setEndsWith3Points(boolean endsWith3Points)
If the Label text is too long fit the text to the widget and add "..." points at the end. By default this is set to true

Parameters:
endsWith3Points - true if text should add "..." at the end

isEndsWith3Points

public boolean isEndsWith3Points()
Simple getter

Returns:
true if this Label adds "..." when the text is too long

animate

public boolean animate()
Overrides:
animate in class Component

setWidth

public void setWidth(int width)
Description copied from class: Component
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 effect the component size setPreferredSize should be used.

Overrides:
setWidth in class Component
Parameters:
width - the width of the component
See Also:
Component.setPreferredSize(Dimension)

setSize

public void setSize(Dimension d)
Description copied from class: Component
Sets the Component size, this method is exposed for the purpose of external layout managers and should not be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.

Overrides:
setSize in class Component
Parameters:
d - the component dimension
See Also:
Component.setPreferredSize(Dimension)