Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2004

Tip: Looking for answers? Try searching our database.

Problems with displaying CSS in a JEditorPane

Thread view: 
Christian Marko - 05 Oct 2004 08:46 GMT
Hi to all!

I have the following problem:
I want to import an external CSS-file but the defined color of the
styles are not displayed (always black is taken).

Does anyone can give me a hint, why this problem occurs?

As I read in the documentation, the attributes white-space and
text-indent are not rendered. Does anyone know a workaround, because
these attributes are also defined in the CSS-file I got?

Example:

JEditorPane pane = new JEditorPane();

try
{
 pane.setPage(getClass().getResource("/myHtmlFile.htm"));
}
catch (Exception e)
{
 e.printStackTrace();
}

StyleSheet ss = ((HTMLDocument)pane.getDocument()).getStyleSheet();
try
{
 styles.importStyleSheet(getClass().getResource("/myCSSFile.css"));
}
catch (Exception e)
{
 e.printStackTrace();
}

thx
Chris
Christian Kaufhold - 14 Oct 2004 15:37 GMT
> I want to import an external CSS-file but the defined color of the
> styles are not displayed (always black is taken).
>
> Does anyone can give me a hint, why this problem occurs?

Maybe the CSS syntax is wrong, maybe something else is wrong. Please
post a complete compilable example.

> As I read in the documentation, the attributes white-space and
> text-indent are not rendered. Does anyone know a workaround, because
[quoted text clipped - 14 lines]
>
> StyleSheet ss = ((HTMLDocument)pane.getDocument()).getStyleSheet();
            ^^

It may not be a good idea to do it this way as setPage modifies the
Document asynchronously. I'd change this in the EditorKit.

> try
> {
>  styles.importStyleSheet(getClass().getResource("/myCSSFile.css"));
  ^^^^^^

Is this your real code?

Christian


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.