How to write text开发者_JS百科 in two rows inside a JLabel ( It doesn't work with \n
) ?
Try to make it like this: JLabel myLabel = new JLabel("<html>this is line1<br>this is line2</html>");
JLabel label = new JLabel("<html>Two<br/>lines</html>");
See How to Use HTML in Swing Components
go for "<html> one <br/> two </html>"
jLabel.add("<html>a<br/>b</html>");
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>");
精彩评论