Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add new line in a JLabel with variables

I understand you can make a new line using <html> <br> </html> but when I add a variable (is a string type) to the text of a label this command doesn't work any more.

label.setText("blahblahblah" + variable + "<html><br>blahblahblah</html>");

I need it to output:

blahblahblah
blahblahblah

like image 626
Runeony1 Avatar asked Nov 14 '12 01:11

Runeony1


2 Answers

You need to have the <html> tag as the first thing in your String:

label.setText("<html>blahblahblah" + variable + "<br>blahblahblah</html>");
like image 143
mercutio Avatar answered Nov 20 '22 05:11

mercutio


It should be:

label.setText("<html>blahblahblah" + variable + "<br>blahblahblah</html>");
like image 20
AsirC Avatar answered Nov 20 '22 06:11

AsirC