Hi,
I'm displaying HTML in a JEditorPane and am trying to use CSS to format it. I can successfully redefine tags such as <h1> <p> etc but new style classes such as .test and id's such as #test1 are ignored.
my style sheet is as follows:
h2 {
font-weight: bold;
font-size: 12pt;
color: #003366;
text-align: right;
padding-right: 7px;
padding-bottom: 6px;
}
p {
font-size: 12pt;
padding-left: 7px;
padding-bottom: 6px;
}
h1{
font-weight: bold;
font-size: 14pt;
color: #66002B;
text-align: center;
padding-top: 5px;
padding-bottom: 8px;
}
h3 {
font-weight: bold;
font-size: 12pt;
color: #000000;
text-align: right;
}
.test{
font-size: 20pt;
text-align right;
}
#test1{
font-size: 20pt;
text-align right;
}
pretty simple! And I load it into my JEditor pane with the following code:
m_styles = new StyleSheet();
URL reference = new URL("file:H:/misc/kstyles.css");
m_styles.loadRules(new FileReader("H:\\misc\\kstyles.css"), reference);
HTMLEditorKit ek = new HTMLEditorKit();
ek.setStyleSheet(m_styles);
pane.setEditorKit(ek);
.....
The html used is :
<link href="kstyles.css" rel="stylesheet" type="text/css">
..
..
<tr>
<td class="test">Open / Close</td>
<td id="test1">massive</td>
<td><h2>Dividend yield:</h2></td>
<td><p></p></td>
</tr>
The redefined <h2> and <p> are rendered correctly but the others are not.
The only thing I can think of is that maybe when I set my reference URL I am not doing it properly
URL reference = new URL("file:H:/misc/kstyles.css");
any help would be greatly appreciated, I have looked at many similar posts here but can't seem to be able to apply what they say to what 'ss going wrong in my case.
Thanks in advance!
Garry