travolta andersson
travolta andersson

Reputation: 77

Problems to linebreak with an int in JLabel

I'm having problems with a linebreak in a JLabel. I want to have a text(name) at the top and beneith the text I want to have an int(to keep score). I have tried this but the int does not show. It shows without the html code but on the same line.

JLabel p1 = new JLabel(<html>Player 1<br> " " </html> + pointPlayer1); 

Suggestions?

Upvotes: 2

Views: 209

Answers (2)

JB Nizet
JB Nizet

Reputation: 691715

new JLabel("<html>Player 1<br>" + pointPlayer1 + "</html>");

The whole string must be inside the html opening and closing tags.

Upvotes: 1

gprathour
gprathour

Reputation: 15333

Try something like this :

JLabel p1 = new JLabel("Player 1 \n "+ pointPlayer1);  

Upvotes: 0

Related Questions