java.awt
Class Label

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Label
All Implemented Interfaces:
java.awt.image.ImageObserver

public class Label
extends Component

A component that displays a single line of read-only text.


Field Summary
static int CENTER
          The center alignment.
static int LEFT
          The left alignment.
static int RIGHT
          The right alignment.
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Label()
          Constructs an empty label.
Label(String label)
          Constructs a new label with the specified String of text.
Label(String label, int alignment)
          Constructs a new label with the specified String of text and the specified alignment.
 
Method Summary
 void addNotify()
          Creates the peer for this label.
 int getAlignment()
          Gets the current alignment of this label.
 String getText()
          Gets the text of this label.
protected  String paramString()
          Returns the parameter String of this label.
 void setAlignment(int alignment)
          Sets the alignment for this label to the specified alignment.
 void setText(String label)
          Sets the text for this label to the specified text.
 
Methods inherited from class java.awt.Component
action, bounds, checkImage, checkImage, createImage, createImage, deliverEvent, disable, enable, enable, getBackground, getColorModel, getFont, getFontMetrics, getForeground, getGraphics, getParent, getPeer, getToolkit, gotFocus, handleEvent, hide, imageUpdate, inside, invalidate, isEnabled, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, removeNotify, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setFont, setForeground, show, show, size, toString, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
The left alignment.

See Also:
Constant Field Values

CENTER

public static final int CENTER
The center alignment.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
The right alignment.

See Also:
Constant Field Values
Constructor Detail

Label

public Label()
Constructs an empty label.


Label

public Label(String label)
Constructs a new label with the specified String of text.

Parameters:
label - the text that makes up the label

Label

public Label(String label,
             int alignment)
Constructs a new label with the specified String of text and the specified alignment.

Parameters:
label - the String that makes up the label
alignment - the alignment value
Method Detail

addNotify

public void addNotify()
Creates the peer for this label. The peer allows us to modify the appearance of the label without changing its functionality.

Overrides:
addNotify in class Component
See Also:
Component.getPeer(), Component.removeNotify()

getAlignment

public int getAlignment()
Gets the current alignment of this label.

See Also:
setAlignment(int)

setAlignment

public void setAlignment(int alignment)
Sets the alignment for this label to the specified alignment.

Parameters:
alignment - the alignment value
Throws:
IllegalArgumentException - If an improper alignment was given.
See Also:
getAlignment()

getText

public String getText()
Gets the text of this label.

See Also:
setText(java.lang.String)

setText

public void setText(String label)
Sets the text for this label to the specified text.

Parameters:
label - the text that makes up the label
See Also:
getText()

paramString

protected String paramString()
Returns the parameter String of this label.

Overrides:
paramString in class Component