Class Label
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Label — AWT 1.0 static text, not
JLabel, rendered by an
SLabel peer:
Label total = new Label("Total", Label.RIGHT);
panel.add(total, BorderLayout.NORTH); // fills the region; text right-aligned
total.setText("Total: 42");
The JDK class is text plus a three-value alignment and nothing else —
no listeners at all. Everything a migrator touches beyond the members
below (setBounds, setFont, setForeground,
setVisible, addMouseListener, …) is inherited
Component.
text and alignment are the JDK's fields, and the getters
answer from them on any thread without reaching the peer — so
getText() returns null verbatim where the peer's Vaadin-backed read
would say "". Leaf peer is locked down per R_leaf_peer_lockdown: no
protected (Component peer) ctor, so every instance — including a
user-code subclass — peers over an SLabel.
The alignment constants are java.awt.Label's own
(0/1/2) and collide numerically with SwingConstants'
LEFT/CENTER/RIGHT (2/0/4) — a value borrowed from the Swing set
means something else here, or throws.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCenter the label's text.static final intLeft-align the label's text — the AWT default.static final intRight-align the label's text.Fields inherited from class Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, FILL_CHROME, FILL_DEFAULT, LEFT_ALIGNMENT, listenerList, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidintgetText()protected StringvoidsetAlignment(int alignment) voidMethods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyBackgroundToPeer, applyComponentOrientation, applyVisibleToPeer, areFocusTraversalKeysSet, awtListeners, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, defaultFillCssClass, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, fireComponentEvent, fireHierarchyEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, 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, isThemeDefault, 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, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, suppressMouseBridge, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate, withPeer, withPeerOnLiveUI
-
Field Details
-
LEFT
public static final int LEFTLeft-align the label's text — the AWT default.- See Also:
-
CENTER
public static final int CENTERCenter the label's text.- See Also:
-
RIGHT
public static final int RIGHTRight-align the label's text.- See Also:
-
-
Constructor Details
-
Label
JDK chains this tothis("", LEFT)— the text is empty, not null.- Throws:
HeadlessException
-
Label
- Throws:
HeadlessException
-
Label
- Parameters:
text- null is legal and reads back fromgetText()verbatimalignment-LEFT/CENTER/RIGHT- Throws:
IllegalArgumentException- on any other alignment, as in AWTHeadlessException- never in practice — the clause is kept for signature fidelity, matchingFrame
-
-
Method Details
-
addNotify
-
getText
- Returns:
- the text as stored — null when constructed or set with null
-
setText
- Parameters:
text- null is stored and read back verbatim; the peer renders blank
-
getAlignment
public int getAlignment() -
setAlignment
public void setAlignment(int alignment) - Throws:
IllegalArgumentException- on a value outsideLEFT/CENTER/RIGHT, as in AWT (R_match_swing_errors)
-
paramString
- Overrides:
paramStringin classComponent
-
getAccessibleContext
- Specified by:
getAccessibleContextin interfaceAccessible- Overrides:
getAccessibleContextin classComponent
-