How to add a new line in JLabel with variables

I understand that you can create a new line using <html> <br> </html> , but when I add a variable (line type) to the label text, this command no longer works.

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

I need this to output:

blahblahblah
blahblahblah

+6
source share
2 answers

You need to have the <html> as the first thing on your line:

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

It should be:

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

All Articles