开发者

Two rows of text inside a JLabel

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜