JLabel – Alignment


Change Text and Icon Alignment – HORIZONTAL

jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
Description:
    Shifts the text and icon's horizontal location around the available JLabel width

Reset:
    jLabel1.setHorizontalAlignment(SwingConstants.LEADING);

Possible Values:
    SwingConstants.LEADING (10) - default
    SwingConstants.LEFT (2)
    SwingConstants.CENTER (0)
    SwingConstants.RIGHT (4)
    SwingConstants.TRAILING (11)

Change Text and Icon Alignment – VERTICAL

jLabel1.setVerticalAlignment(SwingConstants.TOP);
Description:
    Shifts the text and icon's vertical location around the available JLabel height

Reset:
    jLabel1.setVerticalAlignment(SwingConstants.CENTER);

Possible Values:
    SwingConstants.TOP (1)
    SwingConstants.CENTER (0) - default
    SwingConstants.BOTTOM (3)

Change Text Position Relative to Icon – HORIZONTAL

jLabel1.setHorizontalTextPosition(SwingConstants.RIGHT);
Reset:
    jLabel1.setHorizontalTextPosition(SwingConstants.TRAILING);

Possible Values:
    SwingConstants.LEADING (10)
    SwingConstants.LEFT (2)
    SwingConstants.CENTER (0)
    SwingConstants.RIGHT (4)
    SwingConstants.TRAILING (11) - default

Change Text Position Relative to Icon – VERTICAL

jLabel1.setVerticalTextPosition(SwingConstants.TOP);
Reset:
    jLabel1.setVerticalTextPosition(SwingConstants.CENTER);

Possible Values:
    SwingConstants.TOP (1)
    SwingConstants.CENTER (0) - default
    SwingConstants.BOTTOM (3)