Bilal Syed Hussain
Bilal Syed Hussain

Reputation: 9214

How to put the text of a JLabel under its icon

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?


Upvotes: 16

Views: 13257

Answers (1)

icyrock.com
icyrock.com

Reputation: 28618

See this:

Basically, use this in your case:

north.setHorizontalTextPosition(JLabel.CENTER);
north.setVerticalTextPosition(JLabel.BOTTOM);

Upvotes: 36

Related Questions