Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > style sheet

Reply
Thread Tools

style sheet

 
 
Roedy Green
Guest
Posts: n/a
 
      03-30-2009
If you render HTML in Java with for example a JEditorPane, is there a
way to use a style sheet that lives as a resource in a jar?
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Don’t worry about the world coming to an end today.
It is already tomorrow in Australia."
~ Charles Schulz
 
Reply With Quote
 
 
 
 
Jon Gómez
Guest
Posts: n/a
 
      03-31-2009
Roedy Green wrote:
> If you render HTML in Java with for example a JEditorPane, is there a
> way to use a style sheet that lives as a resource in a jar?


I did some quick research, and I found the StyleSheet class:

http://java.sun.com/javase/6/docs/ap...tyleSheet.html

It says it can parse a string of css-like statements, using
StyleSheet.addRule(String):

"Adds a set of rules to the sheet. The rules are expected to be in valid
CSS format. Typically this would be called as a result of parsing a
<style> tag."

It has some limitations, and is not a full implementation of CSS. You
can use such a StyleSheet with the HTMLEditorKit class:

http://java.sun.com/javase/6/docs/ap...EditorKit.html

You can use this in turn with the JEditorPane.

You could store the style sheet as a text file in the JAR, and then load
it, add it to a StyleSheet, and apply that up to the JEditorPane.
Perhaps that'll do what you want?

I tried it myself, and it seems to work.

Jon.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Content Page specific style style sheet rshillington@gmail.com ASP .Net 0 07-14-2006 03:45 PM
Firefox screwing with my style sheet margins! Bill Firefox 14 11-18-2005 03:30 PM
Need help with Style conversion from Style object to Style key/value collection. Ken Varn ASP .Net Building Controls 0 04-26-2004 07:06 PM
Cascading Style Sheet Jim Heavey ASP .Net 3 11-19-2003 06:14 PM
Adding style sheet dynamicaly Marc Nederhoff ASP .Net 2 11-05-2003 04:56 PM



Advertisments