16

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?


Bilal Syed Hussain
  • 8,664
  • 11
  • 38
  • 44

1 Answers1

36

See this:

Basically, use this in your case:

north.setHorizontalTextPosition(JLabel.CENTER);
north.setVerticalTextPosition(JLabel.BOTTOM);
icyrock.com
  • 27,952
  • 4
  • 66
  • 85