Nikhar
Nikhar

Reputation: 1074

JTextPane shows color different from browser of an HTML

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.

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>

I am simply calling setPage for JTextPane.

This is how it is displayed in the JTextPane

This is how it is displayed in the JTextPane

This is how it should be dislplayed(it is from firefox) This is how it should be dislplayed(it is from firefox)

Upvotes: 1

Views: 220

Answers (2)

andreas
andreas

Reputation: 8004

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;

Upvotes: 1

Naveed Quadri
Naveed Quadri

Reputation: 508

I think thats because JTextpane doesnt support css.

Edit: try something like this

<div height ="200" width="100" bgcolor="Silver">this the div tag  </div>

Upvotes: 0

Related Questions