JLabel (Java Platform SE 7 )

A display area for a short text string or an image, or both. A label does not react to input events. As a result, it cannot get the keyboard focus. A label can, however, display a keyboard alternative as a convenience for a nearby component that has a keyboard alternative but can’t display it.

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 JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder.