在 JLabel 中使用 int 换行的问题 [英] Problems to linebreak with an int in JLabel
本文介绍了在 JLabel 中使用 int 换行的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 JLabel
中遇到换行符问题.我想在顶部有一个文本(名称),在我想要一个 int(保持分数)的文本下方.我试过这个,但 int 没有显示.它显示没有 html 代码,但在同一行.
I'm having problems with a linebreak in a JLabel
. I want to have a text(name) at the top and beneith the text I want to have an int(to keep score). I have tried this but the int does not show. It shows without the html code but on the same line.
JLabel p1 = new JLabel(<html>Player 1<br> " " </html> + pointPlayer1);
建议?
推荐答案
new JLabel("<html>Player 1<br>" + pointPlayer1 + "</html>");
整个字符串必须在 html 开始和结束标记内.
The whole string must be inside the html opening and closing tags.
这篇关于在 JLabel 中使用 int 换行的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文