public class Label extends Component implements Accessible
| Modifier and Type | Class and Description |
|---|---|
protected class |
Label.AccessibleAWTLabel
This class provides accessibility support for the label.
|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
static int |
CENTER
Alignment constant aligning the text in the center of its window.
|
static int |
LEFT
Alignment constant aligning the text to the left of its window.
|
static int |
RIGHT
Alignment constant aligning the text to the right of its window.
|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
Label()
Initializes a new instance of
Label with no text. |
Label(String text)
Initializes a new instance of
Label with the specified
text that is aligned to the left. |
Label(String text,
int alignment)
Initializes a new instance of
Label with the specified
text and alignment. |
| Modifier and Type | Method and Description |
|---|---|
void |
addNotify()
Notifies this label that it has been added to a container, causing
the peer to be created.
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this
Label. |
int |
getAlignment()
Returns the constant indicating the alignment of the text in this
label.
|
String |
getText()
Returns the text displayed in this label.
|
protected String |
paramString()
Returns a parameter string useful for debugging.
|
void |
setAlignment(int alignment)
Sets the text alignment of this label to the specified value.
|
void |
setText(String text)
Sets the text in this label to the specified value.
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, 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, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validatepublic static final int LEFT
public static final int CENTER
public static final int RIGHT
public Label()
Label with no text.HeadlessException - If GraphicsEnvironment.isHeadless() is true.public Label(String text)
Label with the specified
text that is aligned to the left.text - The text of the label.HeadlessException - If GraphicsEnvironment.isHeadless() is true.public Label(String text, int alignment)
Label with the specified
text and alignment.text - The text of the label.alignment - The desired alignment for the text in this label,
which must be one of LEFT, CENTER, or
RIGHT.HeadlessException - If GraphicsEnvironment.isHeadless() is true.public int getAlignment()
public void setAlignment(int alignment)
alignment - The desired alignment for the text in this label,
which must be one of LEFT, CENTER, or
RIGHT.public String getText()
public void setText(String text)
text - The new text for this label.public void addNotify()
addNotify in class ComponentComponent.isDisplayable(),
Component.removeNotify()protected String paramString()
paramString in class Componentpublic AccessibleContext getAccessibleContext()
Label.
The context is created, if necessary.getAccessibleContext in interface AccessiblegetAccessibleContext in class Component