Java javax.swing JLabel fields, constructors, methods, implement or subclass

Example usage for Java javax.swing JLabel fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for javax.swing JLabel.

The text is from its open source code.

Subclass

javax.swing.JLabel has subclasses.
Click this link to see all its subclasses.

Constructor

JLabel(String text, int horizontalAlignment)
Creates a JLabel instance with the specified text and horizontal alignment.
JLabel(Icon image, int horizontalAlignment)
Creates a JLabel instance with the specified image and horizontal alignment.
JLabel(String text)
Creates a JLabel instance with the specified text.
JLabel(Icon image)
Creates a JLabel instance with the specified image.
JLabel(String text, Icon icon, int horizontalAlignment)
Creates a JLabel instance with the specified text, image, and horizontal alignment.
JLabel()
Creates a JLabel instance with no image and with an empty string for the title.

Method

Componentadd(Component comp)
Appends the specified component to the end of this container.
Componentadd(String name, Component comp)
Adds the specified component to this container.
voidaddFocusListener(FocusListener l)
Adds the specified focus listener to receive focus events from this component when this component gains input focus.
voidaddMouseListener(MouseListener l)
Adds the specified mouse listener to receive mouse events from this component.
voidaddMouseMotionListener(MouseMotionListener l)
Adds the specified mouse motion listener to receive mouse motion events from this component.
booleanequals(Object obj)
Indicates whether some other object is "equal to" this one.
AccessibleContextgetAccessibleContext()
Get the AccessibleContext of this object
ColorgetBackground()
Gets the background color of this component.
BordergetBorder()
Returns the border of this component or null if no border is currently set.
RectanglegetBounds()
Gets the bounds of this component in the form of a Rectangle object.
IcongetDisabledIcon()
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.
FontgetFont()
Gets the font of this component.
FontMetricsgetFontMetrics(Font font)
Gets the FontMetrics for the specified Font.
ColorgetForeground()
Gets the foreground color of this component.
GraphicsgetGraphics()
Returns this component's graphics context, which lets you draw on a component.
intgetHeight()
Returns the current height of this component.
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.
InsetsgetInsets(Insets insets)
Returns an Insets object containing this component's inset values.
ComponentgetLabelFor()
Get the component this is labelling.
PointgetLocation()
Gets the location of this component in the form of a point specifying the component's top-left corner.
PointgetLocationOnScreen()
Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space.
DimensiongetMinimumSize()
If the minimum size has been set to a non-null value just returns it.
StringgetName()
Gets the name of the component.
ContainergetParent()
Gets the parent of this component.
DimensiongetPreferredSize()
If the preferredSize has been set to a non-null value just returns it.
DimensiongetSize()
Returns the size of this component in the form of a Dimension object.
StringgetText()
Returns the text string that the label displays.
StringgetToolTipText()
Returns the tooltip string that has been set with setToolTipText.
TransferHandlergetTransferHandler()
Gets the transferHandler property.
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.
intgetWidth()
Returns the current width of this component.
intgetX()
Returns the current x coordinate of the component's origin.
intgetY()
Returns the current y coordinate of the component's origin.
booleanisEnabled()
Determines whether this component is enabled.
booleanisOpaque()
Returns true if this component is completely opaque.
booleanisVisible()
Determines whether this component should be visible when its parent is visible.
voidpaint(Graphics g)
Invoked by Swing to draw components.
voidputClientProperty(Object key, Object value)
Adds an arbitrary key/value "client property" to this component.
voidremoveMouseListener(MouseListener l)
Removes the specified mouse listener so that it no longer receives mouse events from this component.
voidrepaint()
Repaints this component.
voidrevalidate()
Supports deferred automatic layout.
voidsetAlignmentX(float alignmentX)
Sets the horizontal alignment.
voidsetAlignmentY(float alignmentY)
Sets the vertical alignment.
voidsetAutoscrolls(boolean autoscrolls)
Sets the autoscrolls property.
voidsetBackground(Color bg)
Sets the background color of this component.
voidsetBorder(Border border)
Sets the border of this component.
voidsetBounds(int x, int y, int width, int height)
Moves and resizes this component.
voidsetBounds(Rectangle r)
Moves and resizes this component to conform to the new bounding rectangle r .
voidsetComponentOrientation(ComponentOrientation o)
Sets the language-sensitive orientation that is to be used to order the elements or text within this component.
voidsetComponentPopupMenu(JPopupMenu popup)
Sets the JPopupMenu for this JComponent.
voidsetCursor(Cursor cursor)
Sets the cursor image to the specified cursor.
voidsetDisabledIcon(Icon disabledIcon)
Set the icon to be displayed if this JLabel is "disabled" (JLabel.setEnabled(false)).
voidsetDisplayedMnemonic(int key)
Specify a keycode that indicates a mnemonic key.
voidsetDisplayedMnemonic(char aChar)
Specifies the displayedMnemonic as a char value.
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.
voidsetEnabled(boolean enabled)
Sets whether or not this component is enabled.
voidsetFocusable(boolean focusable)
Sets the focusable state of this Component to the specified value.
voidsetFocusCycleRoot(boolean focusCycleRoot)
Sets whether this Container is the root of a focus traversal cycle.
voidsetFont(Font font)
Sets the font for this component.
voidsetForeground(Color fg)
Sets the foreground color of this component.
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.
voidsetLayout(LayoutManager mgr)
Sets the layout manager for this container.
voidsetLocation(int x, int y)
Moves this component to a new location.
voidsetLocation(Point p)
Moves this component to a new location.
voidsetMaximumSize(Dimension maximumSize)
Sets the maximum size of this component to a constant value.
voidsetMinimumSize(Dimension minimumSize)
Sets the minimum size of this component to a constant value.
voidsetName(String name)
Sets the name of the component to the specified string.
voidsetOpaque(boolean isOpaque)
If true the component paints every pixel within its bounds.
voidsetPreferredSize(Dimension preferredSize)
Sets the preferred size of this component.
voidsetSize(int width, int height)
Resizes this component so that it has width width and height height .
voidsetSize(Dimension d)
Resizes this component so that it has width d.width and height d.height .
voidsetText(String text)
Defines the single line of text this component will display.
voidsetToolTipText(String text)
Registers the text to display in a tool tip.
voidsetTransferHandler(TransferHandler newHandler)
Sets the TransferHandler , which provides support for transfer of data into and out of this component via cut/copy/paste and drag and drop.
voidsetUI(LabelUI ui)
Sets the L&F object that renders this component.
voidsetVerifyInputWhenFocusTarget(boolean verifyInputWhenFocusTarget)
Sets the value to indicate whether input verifier for the current focus owner will be called before this component requests focus.
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.
voidsetVisible(boolean aFlag)
Makes the component visible or invisible.
voidvalidate()
Validates this container and all of its subcomponents.