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.
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.
The lebels and icon position will be changed as you change the window size.You need to use gridLayout() function to position the labels.
Post a Comment