nextapp.echo
Class Label

java.lang.Object
  extended by nextapp.echo.AbstractComponent
      extended by nextapp.echo.Label
All Implemented Interfaces:
java.io.Serializable, Component
Direct Known Subclasses:
DefaultTreeCellRenderer, Label

public class Label
extends AbstractComponent

A display area for text, an image, or both.

See Also:
Serialized Form

Field Summary
static java.lang.String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
           
static java.lang.String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
           
static java.lang.String ICON_CHANGED_PROPERTY
           
static java.lang.String ICON_TEXT_MARGIN_CHANGED_PROPERTY
           
static java.lang.String STYLE_HORIZONTAL_ALIGNMENT
          A style constant for the Horizontal Alignment property.
static java.lang.String STYLE_HORIZONTAL_TEXT_POSITION
          A style constant for the Horizontal Text Position property.
static java.lang.String STYLE_ICON_TEXT_MARGIN
          A style constant for the Icon-Text Margin property.
static java.lang.String STYLE_VERTICAL_ALIGNMENT
          A style constant for the Vertical Alignment property.
static java.lang.String STYLE_VERTICAL_TEXT_POSITION
          A style constant for the Vertical Text Position property.
static java.lang.String TEXT_CHANGED_PROPERTY
           
static java.lang.String VERTICAL_ALIGNMENT_CHANGED_PROPERTY
           
static java.lang.String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
           
 
Fields inherited from interface nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, SELECTABLE_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
Label()
          Creates a label with no text or icon.
Label(ImageReference icon)
          Creates a label with an icon.
Label(java.lang.String text)
          Creates a label with text.
Label(java.lang.String text, ImageReference icon)
          Creates a label with text and an icon.
 
Method Summary
 void applyStyle(Style style)
          Sets stylistic properties of this component based on a Style object.
 int getHorizontalAlignment()
          Returns the horizontal alignment of the text relative to the icon.
 int getHorizontalTextPosition()
          Returns the horizontal position of the text relative to the icon.
 ImageReference getIcon()
          Returns the icon.
 int getIconTextMargin()
          Returns the size of the margin to be displayed between the icon and text The margin is only drawn if both icon and text are present.
 java.lang.String getText()
          Returns the text.
 int getVerticalAlignment()
          Returns the vertical alignment of the text relative to the icon.
 int getVerticalTextPosition()
          Returns the vertical position of the text relative to the icon.
 void setHorizontalAlignment(int newValue)
          Sets the horizontal alignment of the text relative to the icon.
 void setHorizontalTextPosition(int newValue)
          Sets the horizontal position of the text relative to the icon.
 void setIcon(ImageReference newValue)
          Sets the icon to be displayed.
 void setIconTextMargin(int newValue)
          Sets the size of the margin to be displayed between the icon and text.
 void setText(java.lang.String newValue)
          Sets the text to be displayed.
 void setVerticalAlignment(int newValue)
          Sets the vertical alignment of the text relative to the icon.
 void setVerticalTextPosition(int newValue)
          Sets the vertical position of the text relative to the icon.
 
Methods inherited from class nextapp.echo.AbstractComponent
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getClientId, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getListenerList, getLocale, getParent, indexOf, init, isAncestorOf, isDifferent, isEnabled, isFocused, isRecursivelyVisible, isRegistered, isSelectableForScriptRecorder, isShowing, isVisible, processHierarchyEvent, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setClientId, setEnabled, setFocused, setFont, setForeground, setIdentifier, setLocale, setParent, setRegistered, setSelectableForScriptRecorder, setVisible, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STYLE_HORIZONTAL_ALIGNMENT

public static final java.lang.String STYLE_HORIZONTAL_ALIGNMENT
A style constant for the Horizontal Alignment property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_HORIZONTAL_TEXT_POSITION

public static final java.lang.String STYLE_HORIZONTAL_TEXT_POSITION
A style constant for the Horizontal Text Position property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_ICON_TEXT_MARGIN

public static final java.lang.String STYLE_ICON_TEXT_MARGIN
A style constant for the Icon-Text Margin property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_VERTICAL_ALIGNMENT

public static final java.lang.String STYLE_VERTICAL_ALIGNMENT
A style constant for the Vertical Alignment property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_VERTICAL_TEXT_POSITION

public static final java.lang.String STYLE_VERTICAL_TEXT_POSITION
A style constant for the Vertical Text Position property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY

public static final java.lang.String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
See Also:
Constant Field Values

HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY

public static final java.lang.String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
See Also:
Constant Field Values

ICON_CHANGED_PROPERTY

public static final java.lang.String ICON_CHANGED_PROPERTY
See Also:
Constant Field Values

ICON_TEXT_MARGIN_CHANGED_PROPERTY

public static final java.lang.String ICON_TEXT_MARGIN_CHANGED_PROPERTY
See Also:
Constant Field Values

TEXT_CHANGED_PROPERTY

public static final java.lang.String TEXT_CHANGED_PROPERTY
See Also:
Constant Field Values

VERTICAL_ALIGNMENT_CHANGED_PROPERTY

public static final java.lang.String VERTICAL_ALIGNMENT_CHANGED_PROPERTY
See Also:
Constant Field Values

VERTICAL_TEXT_POSITION_CHANGED_PROPERTY

public static final java.lang.String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
See Also:
Constant Field Values
Constructor Detail

Label

public Label()
Creates a label with no text or icon.


Label

public Label(java.lang.String text)
Creates a label with text.

Parameters:
text - The text to be displayed.

Label

public Label(ImageReference icon)
Creates a label with an icon.

Parameters:
icon - The icon to be displayed.

Label

public Label(java.lang.String text,
             ImageReference icon)
Creates a label with text and an icon.

Parameters:
text - The text to be displayed.
icon - The icon to be displayed.
Method Detail

applyStyle

public void applyStyle(Style style)
Description copied from interface: Component
Sets stylistic properties of this component based on a Style object. The version of this method in Component will set foreground and background colors and the font from the style if they are present. Components should override this method if they allow more properties to be set from a style object, and should call super.applyStyle() if necessary.

Specified by:
applyStyle in interface Component
Overrides:
applyStyle in class AbstractComponent
Parameters:
style - The style object from which to retrieve properties for this Component.
See Also:
Component.applyStyle(Style)

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal alignment of the text relative to the icon.

Returns:
The horizontal alignment of the text relative to the icon, one of the following values:
  • EchoConstants.LEFT (the default)
  • EchoConstants.CENTER
  • EchoConstants.RIGHT

getHorizontalTextPosition

public int getHorizontalTextPosition()
Returns the horizontal position of the text relative to the icon.

Returns:
The horizontal position of the text relative to the icon, one of the following values:
  • EchoConstants.LEFT
  • EchoConstants.CENTER
  • EchoConstants.RIGHT (the default)

getIcon

public ImageReference getIcon()
Returns the icon.

Returns:
The icon.

getIconTextMargin

public int getIconTextMargin()
Returns the size of the margin to be displayed between the icon and text The margin is only drawn if both icon and text are present.

Returns:
The size of the margin between the icon and text, in pixels.

getText

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

Returns:
The text.

getVerticalAlignment

public int getVerticalAlignment()
Returns the vertical alignment of the text relative to the icon.

Returns:
The vertical alignment of the text relative to the icon, one of the following values:
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM

getVerticalTextPosition

public int getVerticalTextPosition()
Returns the vertical position of the text relative to the icon.

Returns:
The vertical position of the text relative to the icon, one of the following values:
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM

setHorizontalAlignment

public void setHorizontalAlignment(int newValue)
Sets the horizontal alignment of the text relative to the icon.

Parameters:
newValue - The horizontal alignment of the text relative to the icon, one of the following values:
  • EchoConstants.LEFT (the default)
  • EchoConstants.CENTER
  • EchoConstants.RIGHT

setHorizontalTextPosition

public void setHorizontalTextPosition(int newValue)
Sets the horizontal position of the text relative to the icon.

Parameters:
newValue - The horizontal position of the text relative to the icon, one of the following values.
  • EchoConstants.LEFT
  • EchoConstants.CENTER
  • EchoConstants.RIGHT (the default)

setIcon

public void setIcon(ImageReference newValue)
Sets the icon to be displayed.

Parameters:
newValue - The icon to be displayed.

setIconTextMargin

public void setIconTextMargin(int newValue)
Sets the size of the margin to be displayed between the icon and text. The margin is only drawn if both icon and text are present.

Parameters:
newValue - The size of the margin between the icon and text, in pixels.

setText

public void setText(java.lang.String newValue)
Sets the text to be displayed.

Parameters:
newValue - The text to be displayed.

setVerticalAlignment

public void setVerticalAlignment(int newValue)
Sets the vertical alignment of the text relative to the icon.

Parameters:
newValue - The vertical alignment of the text relative to the icon, one of the following values:
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM

setVerticalTextPosition

public void setVerticalTextPosition(int newValue)
Sets the vertical position of the text relative to the icon.

Parameters:
newValue - The vertical position of the text relative to the icon, one of the following values.
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM