How to put the text of a JLabel under its icon

12,239

See this:

Basically, use this in your case:

north.setHorizontalTextPosition(JLabel.CENTER);
north.setVerticalTextPosition(JLabel.BOTTOM);
Share:
12,239
Bilal Syed Hussain
Author by

Bilal Syed Hussain

Updated on June 03, 2022

Comments

  • Bilal Syed Hussain
    Bilal Syed Hussain almost 2 years

    I trying to put the text of a JLabel under its icon (centered) at the momemnt I can get this

    Current

    using JLabel north = new JLabel("North")

    I tried using html in the label JLabel("<HTML><BR>North</HTML>") but it is not aligned properly. Any suggestions?