Java DTV API 1.0
12-Dec-2008

com.sun.lwuit
Class Label

java.lang.Object
  extended bycom.sun.lwuit.Component
      extended bycom.sun.dtv.ui.MatteEnabledComponent
          extended bycom.sun.dtv.ui.ViewOnlyComponent
              extended bycom.sun.lwuit.Label
All Implemented Interfaces:
Animated, MatteEnabled, StyleListener
Direct Known Subclasses:
Button, DefaultListCellRenderer

public class Label
extends ViewOnlyComponent

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


Field Summary
 
Fields inherited from class com.sun.dtv.ui.ViewOnlyComponent
HORIZONTAL_ALIGN_CENTER, HORIZONTAL_ALIGN_JUSTIFIED, HORIZONTAL_ALIGN_LEFT, HORIZONTAL_ALIGN_RIGHT, SCALE_ASPECT_PROOF, SCALE_NO, SCALE_NO_ASPECT_PROOF, VERTICAL_ALIGN_BOTTOM, VERTICAL_ALIGN_CENTER, VERTICAL_ALIGN_JUSTIFIED, VERTICAL_ALIGN_TOP
 
Fields inherited from class com.sun.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Fields inherited from interface com.sun.dtv.ui.Animated
ALTERNATING, LOOP, REPEATING
 
Constructor Summary
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.
 
Method Summary
 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.
protected  String getUIID()
          Unique identifier for a component, must be overriden for a component so a style can be applied to the component.
 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 below 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)
          Method to paint the component.
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 "..."
 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.
 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.
 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.dtv.ui.ViewOnlyComponent
getAnimateContent, getGraphicContent, getHorizontalAlignment, getInteractionState, getScalingMode, getTextContent, getTextLayoutManager, isOpaque, setAnimateContent, setGraphicContent, setHorizontalAlignment, setInteractionState, setScalingMode, setTextContent, setTextLayoutManager
 
Methods inherited from class com.sun.dtv.ui.MatteEnabledComponent
getMatte, isDoubleBuffered, processEvent, setMatte
 
Methods inherited from class com.sun.lwuit.Component
addFocusListener, contains, deinitialize, fireClicked, getAbsoluteX, getAbsoluteY, getAnimationMode, getBaseline, getBorder, getBottomGap, getBounds, getClientProperty, getComponentForm, getDelay, getHeight, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPosition, getPreferredSize, getRepetitionMode, getScrollAnimationSpeed, getScrollX, getScrollY, getSideGap, getStyle, getWidth, getX, getY, handlesInput, hasFocus, initComponent, isEnabled, isFocusable, isFocusPainted, isInitialized, isRunning, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isVisible, jumpTo, keyPressed, keyReleased, keyRepeated, longKeyPress, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, setAnimationMode, setCellRenderer, setDelay, setEnabled, setFocus, setFocusable, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredSize, setRepetitionMode, setScrollAnimationSpeed, setScrollX, setScrollY, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setStyle, setVisible, setWidth, setX, setY, start, stop, styleChanged, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Label

public Label(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(String text)
Sets the Label text.

Parameters:
text - the string that the label presents.
See Also:
getText()

getText

public String getText()
Returns the label text.

Returns:
the label text
See Also:
setText(java.lang.String)

setIcon

public void setIcon(Image icon)
Sets the Label icon.

Parameters:
icon - the image that the label presents.
See Also:
getIcon()

getIcon

public Image getIcon()
Returns the labels icon.

Returns:
the labels icon
See Also:
setIcon(com.sun.lwuit.Image)

setAlignment

public void setAlignment(int align)
Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT.

Parameters:
align - alignment value
See Also:
getAlignment(), 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.

Overrides:
setVerticalAlignment in class ViewOnlyComponent
Parameters:
valign - alignment value
See Also:
getVerticalAlignment(), 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 below it.

Overrides:
getVerticalAlignment in class ViewOnlyComponent
Returns:
the vertical alignment of the Label one of: CENTER, TOP, BOTTOM
See Also:
setVerticalAlignment(int), Component.CENTER, Component.TOP, Component.BOTTOM

getAlignment

public int getAlignment()
Returns the alignment of the Label.

Returns:
the alignment of the Label one of: CENTER, LEFT, RIGHT
See Also:
setAlignment(int), 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:
getTextPosition(), 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:
setTextPosition(int), 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
See Also:
getGap()

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
See Also:
setGap(int)

getUIID

protected String getUIID()
Description copied from class: Component
Unique identifier for a component, must be overriden for a component so a style can be applied to the component.

Overrides:
getUIID in class Component
Returns:
unique string identifying this component for the style sheet

paramString

protected String paramString()
Description copied from class: Component
Returns a string representing the state of this component. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:
paramString in class Component
Returns:
a string representation of this component's state

paint

public void paint(Graphics g)
Description copied from class: ViewOnlyComponent
Method to paint the component.

Specified by:
paint in interface Animated
Overrides:
paint in class ViewOnlyComponent
Parameters:
g - the graphics context to use for painting.

calcPreferredSize

protected Dimension calcPreferredSize()
Description copied from class: Component
Calculates the preferred size based on component content. This method is invoked lazily by getPreferred size.

Overrides:
calcPreferredSize in class Component
Returns:
the calculated preferred size based on component content

getShiftText

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

Returns:
number of pixels to shift
See Also:
setShiftText(int)

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
See Also:
getShiftText()

startTicker

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

Parameters:
delay - the delay in milliseconds 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 - indicate whether ticker is enabled

isTickerEnabled

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

Returns:
true if ticker is enabled, false otherwise

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()
Description copied from interface: Animated
Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame.

Specified by:
animate in interface Animated
Overrides:
animate in class Component

Java DTV API 1.0
12-Dec-2008

Copyright © 2008 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.