JTextPane显示与HTML浏览器不同的颜色 [英] JTextPane shows color different from browser of an HTML
问题描述
我正在JTextPane
中加载一个简单的HTML页面,该页面显示的颜色与在浏览器中查看时的颜色不同,并且div标签的高度和宽度也发生了变化.
I am loading a simple HTML page in JTextPane
which is showing different color than when viewed in a browser, and also the div tag's height and width are changed.
HTML文件仅具有1个div标签,即:
the HTML file has 1 div tag only nd that is:
<div height ="200" width="100" style="background-color:#0F9">this the div tag </div>
我只是为JTextPane
呼叫setPage
.
这是它在JTextPane中的显示方式
This is how it is displayed in the JTextPane
这是应如何显示(来自Firefox)
This is how it should be dislplayed(it is from firefox)
推荐答案
我只是遇到了同样的问题.如此处所述(http://docs.oracle.com/javase/6/docs/api/javax/swing/text/html/CSS.html),您可以使用background-color.它的值必须包含7个字符,例如
I just ran into the same problem. As documented here (http://docs.oracle.com/javase/6/docs/api/javax/swing/text/html/CSS.html), you can use background-color. The value of it has to contain 7 characters, for example
background-color:#00FF99;
这篇关于JTextPane显示与HTML浏览器不同的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!