A Java Swing component to display a short text string or an image, or both.
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.
Unlike text fields and many other controls, JLabel
s are transparent by default: parent content is visible in places not covered by text and icon, and setting the background colour has no effect. JLabel
can be made opaque by setOpaque(true)
.
Reference: Class JLabel