java.awt
Class Label

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

public class Label
extends Component
implements Accessible

Unsafe:

See Also:
Serialized Form

Field Summary
(package private)  int alignment
          The label's alignment.
private static String base
           
static int CENTER
          Enabled: Indicates that the label should be centered.
static int LEFT
          Enabled: Indicates that the label should be left justified.
private static int nameCounter
           
static int RIGHT
          Enabled: Indicates that the label should be right justified.
private static long serialVersionUID
           
(package private)  String text
          The text of this label.
 
Fields inherited from class java.awt.Component
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, bufferStrategy, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, focusTraversalKeys, font, foreground, graphicsConfig, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, ignoreRepaint, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, mouseWheelListener, mouseWheelListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowFocusListenerK, windowListenerK, windowStateListenerK, x, y
 
Constructor Summary
Label()
          Suppressed: Constructs an empty label.
Label(String text)
          Suppressed: Constructs a new label with the specified string of text, left justified.
Label(String text, int alignment)
          Suppressed: Constructs a new label that presents the specified string of text with the specified alignment.
 
Method Summary
 void addNotify()
          Suppressed: Creates the peer for this label.
(package private)  String constructComponentName()
          Construct a name for this component.
 AccessibleContext getAccessibleContext()
          Suppressed: Gets the AccessibleContext associated with this Label.
 int getAlignment()
          Suppressed: Gets the current alignment of this label.
 String getText()
          Suppressed: Gets the text of this label.
private static void initIDs()
          Initialize JNI field and method IDs
protected  String paramString()
          Returns a string representing the state of this Label.
private  void readObject(ObjectInputStream s)
          Read a label from an object input stream.
 void setAlignment(int alignment)
          Suppressed: Sets the alignment for this label to the specified alignment.
 void setText(String text)
          Suppressed: Sets the text for this label to the specified text.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, adjustListeningChildrenOnParent, applyComponentOrientation, areFocusTraversalKeysSet, areInputMethodsEnabled, autoProcessMouseWheel, autoTransferFocus, bounds, checkGD, checkImage, checkImage, checkWindowClosingException, clearCurrentFocusCycleRootOnHide, clearMostRecentFocusOwnerOnHide, coalesceEvents, contains, contains, containsFocus, countHierarchyMembers, createBufferStrategy, createBufferStrategy, createChildHierarchyEvents, createHierarchyEvents, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, dispatchMouseWheelToAncestor, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, eventTypeEnabled, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getAlignmentX, getAlignmentY, getBackBuffer, getBackground, getBounds, getBounds, getBufferStrategy, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys_NoIDCheck, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initializeFocusTraversalKeys, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusTraversableOverridden, isFontSet, isForegroundSet, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, iterate, keyDown, keyUp, layout, lightweightPaint, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, nextFocusHelper, numListening, paint, paintAll, paintHeavyweightComponents, postEvent, postsOldMouseEvents, preferredSize, prepareImage, prepareImage, print, printAll, printHeavyweightComponents, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusHelper, requestFocusInWindow, requestFocusInWindow, resetGC, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys_NoIDCheck, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setGCFromPeer, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocus, transferFocusBackward, transferFocusUpCycle, update, updateCursorImmediately, 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
Enabled: Indicates that the label should be left justified.


CENTER

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


RIGHT

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

Since:
JDK1.0t.

text

String text
The text of this label. This text can be modified by the program but never by the user.

See Also:
getText(), setText()

alignment

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

See Also:
getAlignment(), setAlignment()

base

private static final String base

nameCounter

private static int nameCounter

serialVersionUID

private static final long serialVersionUID
Constructor Detail

Label

public Label()
      throws HeadlessException
Suppressed: Constructs an empty label. The text of the label is the empty string "".

See Also:
java.awt.GraphicsEnvironment#isHeadless

Label

public Label(String text)
      throws HeadlessException
Suppressed: Constructs a new label with the specified string of text, left justified.

Parameters:
text - the string that the label presents. A null value will be accepted without causing a NullPointerException to be thrown.
See Also:
java.awt.GraphicsEnvironment#isHeadless

Label

public Label(String text,
             int alignment)
      throws HeadlessException
Suppressed: 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. A null value will be accepted without causing a NullPointerException to be thrown.
alignment - the alignment value.
See Also:
java.awt.GraphicsEnvironment#isHeadless
Method Detail

readObject

private void readObject(ObjectInputStream s)
                 throws ClassNotFoundException,
                        IOException,
                        HeadlessException
Read a label from an object input stream.

Parameters:
s - the ObjectInputStream to read
ClassNotFoundException
IOException
HeadlessException
Since:
1.4
See Also:
java.awt.GraphicsEnvironment#isHeadless

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()
Suppressed: 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.isDisplayable(), Component.removeNotify()

getAlignment

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

See Also:
java.awt.Label#setAlignment

setAlignment

public void setAlignment(int alignment)
Suppressed: 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.
See Also:
java.awt.Label#getAlignment

getText

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

Returns:
the text of this label, or null if the text has been set to null.
See Also:
java.awt.Label#setText

setText

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

Parameters:
text - the text that this label displays. If text is null, it is treated for display purposes like an empty string "".
See Also:
java.awt.Label#getText

paramString

protected String paramString()
Returns a string representing the state of this Label. 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:
the parameter string of this label

initIDs

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


getAccessibleContext

public AccessibleContext getAccessibleContext()
Suppressed: Gets the AccessibleContext associated with this Label. For labels, the AccessibleContext takes the form of an AccessibleAWTLabel. A new AccessibleAWTLabel instance is created if necessary.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class Component
Returns:
an AccessibleAWTLabel that serves as the AccessibleContext of this Label


comments?