Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class Label

java.lang.Object
|
+--java.awt.Component
   |
   +--java.awt.Label

All Implemented Interfaces:

Accessible, ImageObserver, MenuContainer, Serializable


public class Label

extends Component

implements Accessible

This component is used for displaying simple text strings that cannot be edited.

Authors:

Field Summary

static intCENTER

Alignment constant aligning the text in the center of its window.
static intLEFT

Alignment constant aligning the text to the left of its window.
static intRIGHT

Alignment constant aligning the text to the right of its window.

Constructor Summary

Label()

Initializes a new instance of Label with no text.
Label(java.lang.String text)

Initializes a new instance of Label with the specified text that is aligned to the left.
Label(java.lang.String text, int alignment)

Initializes a new instance of Label with the specified text and alignment.

Method Summary

voidaddNotify()

Notifies this label that it has been added to a container, causing the peer to be created.
intgetAlignment()

Returns the constant indicating the alignment of the text in this label.
java.lang.StringgetText()

Returns the text displayed in this label.
java.lang.StringparamString()

Returns a parameter string useful for debugging.
synchronized voidsetAlignment(int alignment)

Sets the text alignment of this label to the specified value.
synchronized voidsetText(java.lang.String text)

Sets the text in this label to the specified value.

Field Details

CENTER

public static final int CENTER

Alignment constant aligning the text in the center of its window.


LEFT

public static final int LEFT

Alignment constant aligning the text to the left of its window.


RIGHT

public static final int RIGHT

Alignment constant aligning the text to the right of its window.


Constructor Details

Label

public Label()

Initializes a new instance of Label with no text.

Throws:


Label

public Label(java.lang.String text)

Initializes a new instance of Label with the specified text that is aligned to the left.

Parameters:

Throws:


Label

public Label(java.lang.String text, int alignment)

Initializes a new instance of Label with the specified text and alignment.

Parameters:

Throws:


Method Details

addNotify

public void addNotify()

Notifies this label that it has been added to a container, causing the peer to be created. This method is called internally by the AWT system.


getAlignment

public int getAlignment()

Returns the constant indicating the alignment of the text in this label. The value returned will be one of the alignment constants from this class.

Returns:


getText

public String getText()

Returns the text displayed in this label.

Returns:


paramString

protected String paramString()

Returns a parameter string useful for debugging.


setAlignment

public synchronized void setAlignment(int alignment)

Sets the text alignment of this label to the specified value.

Parameters:


setText

public synchronized void setText(java.lang.String text)

Sets the text in this label to the specified value.

Parameters: