- All Implemented Interfaces:
- ImageObserver,- MenuContainer,- Serializable,- Accessible,- SwingConstants
- Direct Known Subclasses:
- BasicComboBoxRenderer,- DefaultListCellRenderer,- DefaultTableCellRenderer,- DefaultTreeCellRenderer
@JavaBean(defaultProperty="UI", description="A component that displays a short string and an icon.") public class JLabel extends JComponent implements SwingConstants, Accessible
 A JLabel object can display
 either text, an image, or both.
 You can specify where in the label's display area
 the label's contents are aligned
 by setting the vertical and horizontal alignment.
 By default, labels are vertically centered
 in their display area.
 Text-only labels are leading edge aligned, by default;
 image-only labels are horizontally centered, by default.
 
You can also specify the position of the text relative to the image. By default, text is on the trailing edge of the image, with the text and image vertically aligned.
 A label's leading and trailing edge are determined from the value of its
 ComponentOrientation property.  At present, the default
 ComponentOrientation setting maps the leading edge to left and the trailing
 edge to right.
 
 Finally, you can use the setIconTextGap method
 to specify how many pixels
 should appear between the text and the image.
 The default is 4 pixels.
 
See How to Use Labels in The Java Tutorial for further documentation.
Warning: Swing is not thread safe. For more information see Swing's Threading Policy.
 Warning:
 Serialized objects of this class will not be compatible with
 future Swing releases. The current serialization support is
 appropriate for short term storage or RMI between applications running
 the same version of Swing.  As of 1.4, support for long term storage
 of all JavaBeans™
 has been added to the java.beans package.
 Please see XMLEncoder.
- Since:
- 1.2
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classJLabel.AccessibleJLabelThe class used to obtain the accessible role for this object.Nested classes/interfaces declared in class java.awt.ComponentComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
- 
Field SummaryFields Modifier and Type Field Description protected ComponentlabelForThe Component this label is for; null if the label is not the label for a componentFields declared in class javax.swing.JComponentlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields declared in class java.awt.ComponentaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields declared in interface java.awt.image.ImageObserverABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields declared in interface javax.swing.SwingConstantsBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
- 
Constructor SummaryConstructors Constructor Description JLabel()Creates aJLabelinstance with no image and with an empty string for the title.JLabel(String text)Creates aJLabelinstance with the specified text.JLabel(String text, int horizontalAlignment)Creates aJLabelinstance with the specified text and horizontal alignment.JLabel(String text, Icon icon, int horizontalAlignment)Creates aJLabelinstance with the specified text, image, and horizontal alignment.JLabel(Icon image)Creates aJLabelinstance with the specified image.JLabel(Icon image, int horizontalAlignment)Creates aJLabelinstance with the specified image and horizontal alignment.
- 
Method SummaryModifier and Type Method Description protected intcheckHorizontalKey(int key, String message)Verify that key is a legal value for the horizontalAlignment properties.protected intcheckVerticalKey(int key, String message)Verify that key is a legal value for the verticalAlignment or verticalTextPosition properties.AccessibleContextgetAccessibleContext()Get the AccessibleContext of this objectIcongetDisabledIcon()Returns the icon used by the label when it's disabled.intgetDisplayedMnemonic()Return the keycode that indicates a mnemonic key.intgetDisplayedMnemonicIndex()Returns the character, as an index, that the look and feel should provide decoration for as representing the mnemonic character.intgetHorizontalAlignment()Returns the alignment of the label's contents along the X axis.intgetHorizontalTextPosition()Returns the horizontal position of the label's text, relative to its image.IcongetIcon()Returns the graphic image (glyph, icon) that the label displays.intgetIconTextGap()Returns the amount of space between the text and the icon displayed in this label.ComponentgetLabelFor()Get the component this is labelling.StringgetText()Returns the text string that the label displays.LabelUIgetUI()Returns the L&F object that renders this component.StringgetUIClassID()Returns a string that specifies the name of the l&f class that renders this component.intgetVerticalAlignment()Returns the alignment of the label's contents along the Y axis.intgetVerticalTextPosition()Returns the vertical position of the label's text, relative to its image.booleanimageUpdate(Image img, int infoflags, int x, int y, int w, int h)This is overridden to return false if the current Icon's Image is not equal to the passed in Imageimg.protected StringparamString()Returns a string representation of this JLabel.voidsetDisabledIcon(Icon disabledIcon)Set the icon to be displayed if this JLabel is "disabled" (JLabel.setEnabled(false)).voidsetDisplayedMnemonic(char aChar)Specifies the displayedMnemonic as a char value.voidsetDisplayedMnemonic(int key)Specify a keycode that indicates a mnemonic key.voidsetDisplayedMnemonicIndex(int index)Provides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic.voidsetHorizontalAlignment(int alignment)Sets the alignment of the label's contents along the X axis.voidsetHorizontalTextPosition(int textPosition)Sets the horizontal position of the label's text, relative to its image.voidsetIcon(Icon icon)Defines the icon this component will display.voidsetIconTextGap(int iconTextGap)If both the icon and text properties are set, this property defines the space between them.voidsetLabelFor(Component c)Set the component this is labelling.voidsetText(String text)Defines the single line of text this component will display.voidsetUI(LabelUI ui)Sets the L&F object that renders this component.voidsetVerticalAlignment(int alignment)Sets the alignment of the label's contents along the Y axis.voidsetVerticalTextPosition(int textPosition)Sets the vertical position of the label's text, relative to its image.voidupdateUI()Resets the UI property to a value from the current look and feel.Methods declared in class javax.swing.JComponentaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods declared in class java.awt.Containeradd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods declared in class java.awt.Componentaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
- 
Field Details- 
labelForThe Component this label is for; null if the label is not the label for a component
 
- 
- 
Constructor Details- 
JLabelCreates aJLabelinstance with the specified text, image, and horizontal alignment. The label is centered vertically in its display area. The text is on the trailing edge of the image.- Parameters:
- text- The text to be displayed by the label.
- icon- The image to be displayed by the label.
- horizontalAlignment- One of the following constants defined in- SwingConstants:- LEFT,- CENTER,- RIGHT,- LEADINGor- TRAILING.
 
- 
JLabelCreates aJLabelinstance with the specified text and horizontal alignment. The label is centered vertically in its display area.- Parameters:
- text- The text to be displayed by the label.
- horizontalAlignment- One of the following constants defined in- SwingConstants:- LEFT,- CENTER,- RIGHT,- LEADINGor- TRAILING.
 
- 
JLabelCreates aJLabelinstance with the specified text. The label is aligned against the leading edge of its display area, and centered vertically.- Parameters:
- text- The text to be displayed by the label.
 
- 
JLabelCreates aJLabelinstance with the specified image and horizontal alignment. The label is centered vertically in its display area.- Parameters:
- image- The image to be displayed by the label.
- horizontalAlignment- One of the following constants defined in- SwingConstants:- LEFT,- CENTER,- RIGHT,- LEADINGor- TRAILING.
 
- 
JLabelCreates aJLabelinstance with the specified image. The label is centered vertically and horizontally in its display area.- Parameters:
- image- The image to be displayed by the label.
 
- 
JLabelpublic JLabel()Creates aJLabelinstance with no image and with an empty string for the title. The label is centered vertically in its display area. The label's contents, once set, will be displayed on the leading edge of the label's display area.
 
- 
- 
Method Details- 
getUIReturns the L&F object that renders this component.- Overrides:
- getUIin class- JComponent
- Returns:
- LabelUI object
 
- 
setUI@BeanProperty(hidden=true, visualUpdate=true, description="The UI object that implements the Component\'s LookAndFeel.") public void setUI(LabelUI ui)Sets the L&F object that renders this component.- Parameters:
- ui- the LabelUI L&F object
- See Also:
- UIDefaults.getUI(javax.swing.JComponent)
 
- 
updateUIpublic void updateUI()Resets the UI property to a value from the current look and feel.- Overrides:
- updateUIin class- JComponent
- See Also:
- JComponent.updateUI()
 
- 
getUIClassIDReturns a string that specifies the name of the l&f class that renders this component.- Overrides:
- getUIClassIDin class- JComponent
- Returns:
- the string "LabelUI"
- See Also:
- JComponent.getUIClassID(),- UIDefaults.getUI(javax.swing.JComponent)
 
- 
getTextReturns the text string that the label displays.- Returns:
- a String
- See Also:
- setText(java.lang.String)
 
- 
setText@BeanProperty(preferred=true, visualUpdate=true, description="Defines the single line of text this component will display.") public void setText(String text)Defines the single line of text this component will display. If the value of text is null or empty string, nothing is displayed.The default value of this property is null. This is a JavaBeans bound property. - Parameters:
- text- the single line of text this component will display
- See Also:
- setVerticalTextPosition(int),- setHorizontalTextPosition(int),- setIcon(javax.swing.Icon)
 
- 
getIconReturns the graphic image (glyph, icon) that the label displays.- Returns:
- an Icon
- See Also:
- setIcon(javax.swing.Icon)
 
- 
setIcon@BeanProperty(preferred=true, visualUpdate=true, description="The icon this component will display.") public void setIcon(Icon icon)Defines the icon this component will display. If the value of icon is null, nothing is displayed.The default value of this property is null. This is a JavaBeans bound property. - Parameters:
- icon- the default icon this component will display
- See Also:
- setVerticalTextPosition(int),- setHorizontalTextPosition(int),- getIcon()
 
- 
getDisabledIconReturns the icon used by the label when it's disabled. If no disabled icon has been set this will forward the call to the look and feel to construct an appropriate disabled Icon.Some look and feels might not render the disabled Icon, in which case they will ignore this. - Returns:
- the disabledIconproperty
- See Also:
- setDisabledIcon(javax.swing.Icon),- LookAndFeel.getDisabledIcon(javax.swing.JComponent, javax.swing.Icon),- ImageIcon
 
- 
setDisabledIcon@BeanProperty(visualUpdate=true, description="The icon to display if the label is disabled.") public void setDisabledIcon(Icon disabledIcon)Set the icon to be displayed if this JLabel is "disabled" (JLabel.setEnabled(false)).The default value of this property is null. - Parameters:
- disabledIcon- the Icon to display when the component is disabled
- See Also:
- getDisabledIcon(),- JComponent.setEnabled(boolean)
 
- 
setDisplayedMnemonic@BeanProperty(visualUpdate=true, description="The mnemonic keycode.") public void setDisplayedMnemonic(int key)Specify a keycode that indicates a mnemonic key. This property is used when the label is part of a larger component. If the labelFor property of the label is not null, the label will call the requestFocus method of the component specified by the labelFor property when the mnemonic is activated.- Parameters:
- key- a keycode that indicates a mnemonic key
- See Also:
- getLabelFor(),- setLabelFor(java.awt.Component)
 
- 
setDisplayedMnemonicpublic void setDisplayedMnemonic(char aChar)Specifies the displayedMnemonic as a char value.- Parameters:
- aChar- a char specifying the mnemonic to display
- See Also:
- setDisplayedMnemonic(int)
 
- 
getDisplayedMnemonicpublic int getDisplayedMnemonic()Return the keycode that indicates a mnemonic key. This property is used when the label is part of a larger component. If the labelFor property of the label is not null, the label will call the requestFocus method of the component specified by the labelFor property when the mnemonic is activated.- Returns:
- int value for the mnemonic key
- See Also:
- getLabelFor(),- setLabelFor(java.awt.Component)
 
- 
setDisplayedMnemonicIndex@BeanProperty(visualUpdate=true, description="the index into the String to draw the keyboard character mnemonic at") public void setDisplayedMnemonicIndex(int index) throws IllegalArgumentExceptionProvides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic. Not all look and feels may support this. A value of -1 indicates either there is no mnemonic, the mnemonic character is not contained in the string, or the developer does not wish the mnemonic to be displayed.The value of this is updated as the properties relating to the mnemonic change (such as the mnemonic itself, the text...). You should only ever have to call this if you do not wish the default character to be underlined. For example, if the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A' to be decorated, as 'Save As', you would have to invoke setDisplayedMnemonicIndex(5)after invokingsetDisplayedMnemonic(KeyEvent.VK_A).- Parameters:
- index- Index into the String to underline
- Throws:
- IllegalArgumentException- will be thrown if- indexis >= length of the text, or < -1
- Since:
- 1.4
 
- 
getDisplayedMnemonicIndexpublic int getDisplayedMnemonicIndex()Returns the character, as an index, that the look and feel should provide decoration for as representing the mnemonic character.- Returns:
- index representing mnemonic character
- Since:
- 1.4
- See Also:
- setDisplayedMnemonicIndex(int)
 
- 
checkHorizontalKeyVerify that key is a legal value for the horizontalAlignment properties.- Parameters:
- key- the property value to check
- message- the IllegalArgumentException detail message
- Returns:
- the key value if keyis a a legal value for the horizontalAlignment properties
- Throws:
- IllegalArgumentException- if key isn't LEFT, CENTER, RIGHT, LEADING or TRAILING.
- See Also:
- setHorizontalTextPosition(int),- setHorizontalAlignment(int)
 
- 
checkVerticalKeyVerify that key is a legal value for the verticalAlignment or verticalTextPosition properties.- Parameters:
- key- the property value to check
- message- the IllegalArgumentException detail message
- Returns:
- the key value if keyis a legal value for the verticalAlignment or verticalTextPosition properties
- Throws:
- IllegalArgumentException- if key isn't TOP, CENTER, or BOTTOM.
- See Also:
- setVerticalAlignment(int),- setVerticalTextPosition(int)
 
- 
getIconTextGappublic int getIconTextGap()Returns the amount of space between the text and the icon displayed in this label.- Returns:
- an int equal to the number of pixels between the text and the icon.
- See Also:
- setIconTextGap(int)
 
- 
setIconTextGap@BeanProperty(visualUpdate=true, description="If both the icon and text properties are set, this property defines the space between them.") public void setIconTextGap(int iconTextGap)If both the icon and text properties are set, this property defines the space between them.The default value of this property is 4 pixels. This is a JavaBeans bound property. - Parameters:
- iconTextGap- the space between the icon and text properties
- See Also:
- getIconTextGap()
 
- 
getVerticalAlignmentpublic int getVerticalAlignment()Returns the alignment of the label's contents along the Y axis.- Returns:
- The value of the verticalAlignment property, one of the
           following constants defined in SwingConstants:TOP,CENTER, orBOTTOM.
- See Also:
- SwingConstants,- setVerticalAlignment(int)
 
- 
setVerticalAlignment@BeanProperty(visualUpdate=true, enumerationValues={"SwingConstants.TOP","SwingConstants.CENTER","SwingConstants.BOTTOM"}, description="The alignment of the label\'s contents along the Y axis.") public void setVerticalAlignment(int alignment)Sets the alignment of the label's contents along the Y axis.The default value of this property is CENTER. - Parameters:
- alignment- One of the following constants defined in- SwingConstants:- TOP,- CENTER(the default), or- BOTTOM.
- See Also:
- SwingConstants,- getVerticalAlignment()
 
- 
getHorizontalAlignmentpublic int getHorizontalAlignment()Returns the alignment of the label's contents along the X axis.- Returns:
- The value of the horizontalAlignment property, one of the
           following constants defined in SwingConstants:LEFT,CENTER,RIGHT,LEADINGorTRAILING.
- See Also:
- setHorizontalAlignment(int),- SwingConstants
 
- 
setHorizontalAlignment@BeanProperty(visualUpdate=true, enumerationValues={"SwingConstants.LEFT","SwingConstants.CENTER","SwingConstants.RIGHT","SwingConstants.LEADING","SwingConstants.TRAILING"}, description="The alignment of the label\'s content along the X axis.") public void setHorizontalAlignment(int alignment)Sets the alignment of the label's contents along the X axis.This is a JavaBeans bound property. - Parameters:
- alignment- One of the following constants defined in- SwingConstants:- LEFT,- CENTER(the default for image-only labels),- RIGHT,- LEADING(the default for text-only labels) or- TRAILING.
- See Also:
- SwingConstants,- getHorizontalAlignment()
 
- 
getVerticalTextPositionpublic int getVerticalTextPosition()Returns the vertical position of the label's text, relative to its image.- Returns:
- One of the following constants
           defined in SwingConstants:TOP,CENTER, orBOTTOM.
- See Also:
- setVerticalTextPosition(int),- SwingConstants
 
- 
setVerticalTextPosition@BeanProperty(expert=true, visualUpdate=true, enumerationValues={"SwingConstants.TOP","SwingConstants.CENTER","SwingConstants.BOTTOM"}, description="The vertical position of the text relative to it\'s image.") public void setVerticalTextPosition(int textPosition)Sets the vertical position of the label's text, relative to its image.The default value of this property is CENTER. This is a JavaBeans bound property. - Parameters:
- textPosition- One of the following constants defined in- SwingConstants:- TOP,- CENTER(the default), or- BOTTOM.
- See Also:
- SwingConstants,- getVerticalTextPosition()
 
- 
getHorizontalTextPositionpublic int getHorizontalTextPosition()Returns the horizontal position of the label's text, relative to its image.- Returns:
- One of the following constants
           defined in SwingConstants:LEFT,CENTER,RIGHT,LEADINGorTRAILING.
- See Also:
- SwingConstants
 
- 
setHorizontalTextPosition@BeanProperty(expert=true, visualUpdate=true, enumerationValues={"SwingConstants.LEFT","SwingConstants.CENTER","SwingConstants.RIGHT","SwingConstants.LEADING","SwingConstants.TRAILING"}, description="The horizontal position of the label\'s text, relative to its image.") public void setHorizontalTextPosition(int textPosition)Sets the horizontal position of the label's text, relative to its image.- Parameters:
- textPosition- One of the following constants defined in- SwingConstants:- LEFT,- CENTER,- RIGHT,- LEADING, or- TRAILING(the default).
- See Also:
- SwingConstants
 
- 
imageUpdateThis is overridden to return false if the current Icon's Image is not equal to the passed in Imageimg.- Specified by:
- imageUpdatein interface- ImageObserver
- Overrides:
- imageUpdatein class- Component
- Parameters:
- img- the image being observed
- infoflags- see- imageUpdatefor more information
- x- the x coordinate
- y- the y coordinate
- w- the width
- h- the height
- Returns:
- falseif the infoflags indicate that the image is completely loaded;- trueotherwise.
- See Also:
- ImageObserver,- Component.imageUpdate(java.awt.Image, int, int, int, int, int)
 
- 
paramStringReturns a string representation of this JLabel. 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 benull.- Overrides:
- paramStringin class- JComponent
- Returns:
- a string representation of this JLabel.
 
- 
getLabelForGet the component this is labelling.- Returns:
- the Component this is labelling. Can be null if this does not label a Component. If the displayedMnemonic property is set and the labelFor property is also set, the label will call the requestFocus method of the component specified by the labelFor property when the mnemonic is activated.
- See Also:
- getDisplayedMnemonic(),- setDisplayedMnemonic(int)
 
- 
setLabelForSet the component this is labelling. Can be null if this does not label a Component. If the displayedMnemonic property is set and the labelFor property is also set, the label will call the requestFocus method of the component specified by the labelFor property when the mnemonic is activated.- Parameters:
- c- the Component this label is for, or null if the label is not the label for a component
- See Also:
- getDisplayedMnemonic(),- setDisplayedMnemonic(int)
 
- 
getAccessibleContext@BeanProperty(bound=false, expert=true, description="The AccessibleContext associated with this Label.") public AccessibleContext getAccessibleContext()Get the AccessibleContext of this object- Specified by:
- getAccessibleContextin interface- Accessible
- Overrides:
- getAccessibleContextin class- Component
- Returns:
- the AccessibleContext of this object
 
 
-