Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class java.awt.Label

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

public class Label
extends Component
A Label object is a component for placing text in a container. A label displays a single line of read-only text. The text can be changed by the application, but a user cannot edit it directly.

For example, the code . . .


 setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
 add(new Label("Hi There!"));
 add(new Label("Another Label"));
 

produces the following label:

Since:
JDK1.0
Version:
1.32, 06/29/98
See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
Component.NativeInLightFixer
 
Field Summary
int alignment
          The label's alignment.
static String base
           
static int CENTER
          Indicates that the label should be centered.
static int LEFT
          Indicates that the label should be left justified.
static int nameCounter
           
static int RIGHT
          Indicates that the label should be right justified.
static long serialVersionUID
           
String text
          The text of this label.
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, parent, peer, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
Label()
          Constructs an empty label.
Label(String text)
          Constructs a new label with the specified string of text, left justified.
Label(String text, int alignment)
          Constructs a new label that presents the specified string of text with the specified alignment.
 
Method Summary
static void ()
           
void addNotify()
          Creates the peer for this label.
String constructComponentName()
          Construct a name for this component.
int getAlignment()
          Gets the current alignment of this label.
String getText()
          Gets the text of this label.
static void initIDs()
          Initialize JNI field and method IDs
String paramString()
          Returns the parameter string representing the state of this label.
void setAlignment(int alignment)
          Sets the alignment for this label to the specified alignment.
void setText(String text)
          Sets the text for this label to the specified text.
 
Methods inherited from class java.awt.Component
, action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, constructComponentName, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, ensureWindowActivation, eventEnabled, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initIDs, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, postsOldMouseEvents, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, readObject, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate, writeObject
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notifyAll, notify, registerNatives, toString, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
Indicates that the label should be left justified.

CENTER

public static final int CENTER
Indicates that the label should be centered.

RIGHT

public static final int RIGHT
Indicates that the label should be right justified.

text

String text
The text of this label.

alignment

int alignment
The label's alignment. The default alignment is set to be left justified.

base

private static final String base

nameCounter

private static int nameCounter

serialVersionUID

private static final long serialVersionUID
Constructor Detail

Label

public Label()
Constructs an empty label.

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(String text,
             int alignment)
Constructs a new label that presents the specified string of text with the specified alignment.

Possible values for alignment are Label.LEFT, Label.RIGHT, and Label.CENTER.

Parameters:
text - the string that the label presents.
alignment - the alignment value.

Method Detail

static void ()

constructComponentName

String constructComponentName()
Construct a name for this component. Called by getName() when the name is null.
Overrides:
constructComponentName in class Component

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

getAlignment

public int getAlignment()
Gets the current alignment of this label. Possible values are Label.LEFT, Label.RIGHT, and Label.CENTER.
See Also:
setAlignment

setAlignment

public void setAlignment(int alignment)
Sets the alignment for this label to the specified alignment. Possible values are Label.LEFT, Label.RIGHT, and Label.CENTER.
Parameters:
alignment - the alignment to be set.
Throws:
java.lang.IllegalArgumentException - if an improper value for alignment is given.
See Also:
getAlignment

getText

public String getText()
Gets the text of this label.
Returns:
the text of this label.
See Also:
setText

setText

public void setText(String text)
Sets the text for this label to the specified text.
Parameters:
text - the text that this label presents.
See Also:
getText

paramString

protected String paramString()
Returns the parameter string representing the state of this label. This string is useful for debugging.
Returns:
the parameter string of this label.
Overrides:
paramString in class Component

initIDs

private static void initIDs()
Initialize JNI field and method IDs

Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD