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

来源:互联网 发布:键盘组合键软件 编辑:程序博客网 时间:2024/06/06 20:04

从 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.


原创粉丝点击