Reputation: 56189
How to write text in two rows inside a JLabel ( It doesn't work with \n
) ?
Upvotes: 2
Views: 6408
Reputation: 349
Here is also solution if you want to center the two lines in the jlabel.
JLabel label = new JLabel("<html> <center> line1 </center> <center> line2 </center> </html>");
Upvotes: 0
Reputation: 13728
Try to make it like this: JLabel myLabel = new JLabel("<html>this is line1<br>this is line2</html>");
Upvotes: 7
Reputation: 274532
JLabel label = new JLabel("<html>Two<br/>lines</html>");
See How to Use HTML in Swing Components
Upvotes: 6