页面刷新后applet中JLabel无法正常显示HTML文本


从 JRE 1.6.0_22 version 开始如果你的applet中的JLabel使用了HTML代码,applet第一次载入时会正确显示HTML的文本内容,但当你刷新页面后JLable中的HTML文本将不会正确显示。 该问题只有在你的JLable中存在HTML代码才会出现

有一个解决方案, 在init方法中初始化一个解析器,代码如下:

javax.swing.text.html.parser.ParserDelegator parserDelegator = new javax.swing.text.html.parser.ParserDelegator();

问题将被解决。


原文:

HTML text not displayed in JLabel in JApplet in Page Refresh

From JRE 1.6.0_22 version (not sure exactly about the version number and it is my guess which I observed), new problem introduced in JApplet rendering. If you have some labels in your applet with HTML text in them, for the first time applet will be displayed properly. But if you refresh the page, the labels won't display the text. This problem happens only if the label has HTML text in it.

The workaround for that is, instantiate a parser delegator in init method like this.
javax.swing.text.html.parser.ParserDelegator parserDelegator = new javax.swing.text.html.parser.ParserDelegator();
Thats it. The problem will be solved.


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值