开发者

Two rows of text inside a JLabel

开发者 https://www.devze.com 2023-02-04 21:16 出处:网络
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</h

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>");
0

精彩评论

暂无评论...
验证码 换一张
取 消