问题描述
我有以下JLabel代码:
JLabel someJLabel = new JLabel(< html> first line< br>第二行< / html>);
someJLabel.setFont(new Font(Arial,Font.PLAIN,16));
我想要做的是能够控制两条线之间的线高度/间距。
PS:我也看过使用段落而不是breaklines,但是它是一样的。我不知道你是否可以在不使用css的情况下在html标签中做到这一点(你不能在Java Swing中的JLabel的html代码中使用css)。
这应该可以,但事实并非如此。 color:green
虽然可以。
content.add(new JLabel(< html>< p style = \line-height:150%; \> hi< br> world< / p>< / html>));
我猜行高不行。这就是如果你使用CSS,你会这样做,所以也许你不能这样做。 我发现你可以用它来测试你的HTML是否能够快速工作。
I have the following JLabel code:
JLabel someJLabel = new JLabel("<html>first line<br>second line</html>");
someJLabel.setFont(new Font("Arial", Font.PLAIN, 16));
What I'd like to do is be able to control the line height/spacing between the two lines.
PS: I've also looked at using paragraphs instead of breaklines, but it's the same thing. And I don't know if you can do that within an html tag without using css (you can't use css within html code in a JLabel in Java Swing).
This should work, but it's not. color: green
works though.
content.add(new JLabel("<html><p style=\"line-height: 150%;\">hi<br>world</p></html>"));
I guess line-height doesn't work. That's how you'd do it if you were to use CSS, so maybe you can't do it that way. Here's a nice tool I found which you can use to test if your HTML will work quickly.
这篇关于如何在Java Swing中设置JLabel中的行间距/高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!