开发者

Why does JLabel not display '/' when it is the first character?

开发者 https://www.devze.com 2023-04-04 20:45 出处:网络
I have an swing panel with a JLabel inside of it.The开发者_Python百科 JLabel looks like this: new JLabel(\"<html>/Foo <br/>/Bar <br/>/Foo<br/>/Bar</html>\");

I have an swing panel with a JLabel inside of it. The开发者_Python百科 JLabel looks like this:

new JLabel("<html>/Foo <br/>/Bar <br/>/Foo<br/>/Bar</html>");

However it displays in the UI like the following:

Bar

Foo

Bar

For some reason, the first line just disappears. If I take out the slash or remove the html tags, it works as expected. Is there a way to make the first line show up with the slash? The reason this even showed up is that we have JLabels which are populated by third party data. I could programatically remove the slash, but I would prefer to show it in the UI if there is a way to do it. We are using html and the BR tags in order to make sure each value is on a separate line.


I guess its a parsing problem. It works if you add the body tags:

"<html><body>/Foo <br/>/Bar <br/>/Foo<br/>/Bar</body></html>"


This is a known bug. You can find it here in the bug lists.

0

精彩评论

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