Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

JEditorPane and CSS

843804Sep 2 2004 — edited Oct 23 2004
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


Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 20 2004
Added on Sep 2 2004
1 comment
403 views