CSS in JEditorPane

ello,
how do i get this
A, A:Visted, A:Active{
color:#333399;
text-decoration:underline;
A:Hover{
color:#FF6600;
text-decoration:underline;
to work in a JEditorPane. i looked around the forum and no one seems to know.

When enough people ask a question and don't get an answer here, that means there likely isn't an answer. In your case, that means "You can't do that."

Similar Messages

  • Html and CSS in JEditorPane

    I have been working with Velocity to produce dynamic HTML and displaying the results with the JEditorPane. I have been searching for an article or tutorial that talks about the JEditorPane (HTML and CSS related), but nothing has come up (I also did a quick search in this forum).
    I would like to know what is JEditorPane capable of doing in terms of displaying HTML with CSS, and how do you set it up.
    If JEditorPane is not the best option with HTML that has positioning in CSS, can somebody suggest something else that has better support for CSS than JEditorPane?
    I would greatly appreciate any response (Any suggestion or links to additional information will be great too!)
    Thanks,
    Victor Gutierrez

    I would like to know what is JEditorPane capable of
    doing in terms of displaying HTML with CSS, and how
    do you set it up. JEditorPane has no support for CSS
    If JEditorPane is not the best option with HTML thatit's not
    has positioning in CSS, can somebody suggest
    something else that has better support for CSS than
    JEditorPane?Search google for 'JDIC' find the WebBrowser component
    I would greatly appreciate any response (Anylet's not get carried away here
    suggestion or links to additional information will be
    great too!)
    Thanks,
    Victor Gutierrez

  • Handling Javascript and CSS in JEditorPane

    I am just beginning to play around with java.net and URLs, and have the following code snippet:
    URL home = new URL("http://www.google.com");
    JEditorPane ep = new JEditorPane();
    ep.setPage(home);
    ep.setEditable(false);
    ep.addHyperlinkListener(new HLinkListener(ep));
    JScrollPane scroll = new JScrollPane(ep);Where the JEditorPane is inside of a JFrame, and HLinkListener is a seperate class with just the HyperlinkListener interface and hyperlinkUpdate method.
    This works for what I want it to, just a basic GUI representation of a URL, but is unable to handle any pages that involve CSS or JavaScript. Google has turned up many all inclusive packages, like Cobra, but what I was wondering is if anybody has any experience with a particular Java JS/CSS parser, or if there was a basic way, ie one with only a couple of imports and new objects, that would allow JS and CSS to be displayed.

    I would like to know what is JEditorPane capable of
    doing in terms of displaying HTML with CSS, and how
    do you set it up. JEditorPane has no support for CSS
    If JEditorPane is not the best option with HTML thatit's not
    has positioning in CSS, can somebody suggest
    something else that has better support for CSS than
    JEditorPane?Search google for 'JDIC' find the WebBrowser component
    I would greatly appreciate any response (Anylet's not get carried away here
    suggestion or links to additional information will be
    great too!)
    Thanks,
    Victor Gutierrez

  • How to use CSS in JEditorPane?

    I want to dispalay a XML file in JEditorPane with CSS. I have do the following:
    StyleSheet stylesheet=new StyleSheet();
    FileReader in=new FileReader(cssFileName);
    stylesheet.loadRules(in,null);
    HTMLEditorKit kit=(HTMLEditorKit)ShowPane.getEditorKitForContentType("text/html");
    kit.setStyleSheet(stylesheet);
    ShowPane.setEditorKit(kit);
    ShowPane.setPage(this.getClass().getResource(xmlFileName));
    But the stylesheet seems have no effect on the output of the JEditorPane-ShowPane.why?

    JEditorPane with StyleSheets, CSS, is partially supported by Java 2, on level 1, but not perfect. To load it, you should invoke it's loadRules method, passing it a Reader corresponding to the StyleSheet file, using the method : public void loadRules(Reader in, URL ref) throws IOException

  • CSS and JEditorPane

    Hi,
    as a project for school, we have to make a rather basic Java webbrowser. I've used the JEditorPane, and this works fine. Although it does seems to have soms problems with applying the css, specifically inline css. For example: if i try to open google.com, it shows the logo image in different pieces, it doenst align the text (or in the wrong direction) etc etc. I've also used a HTMLEditorKit, but this also doen't do the job.
    Perhaps I'm not doing it right, so excuse me then, but if not, could you please give me some alternatifs.
    Thanks in advance!

    well, considering JEditorPane only supports HTML 3.2 and no Javascript and probably only part of CSS 1, then I wouldn't be surprised.

  • Help please! Going mad with CSS in JEditorPane

    Hi gurus,
    For more then two days now i am trying to get css working with html in my jeditorpane.
    This is the stylesheet:
    .toc1
    font-size:12.0pt;
    font-family:Arial;
    font-weight:bold;
    margin-bottom: 0px;
    .toc2
    font-size:11.0pt;
    font-family:"Times New Roman";
    margin-left: 20px;
    margin-top: 0px;
    margin-bottom: 0px;
    .plannerhyperlink
    color:green;
    text-decoration:italic;
    SIMPLE isn't it?
    In my JEditorPane constructor I do this
    StyleSheet styleSheet = new StyleSheet();
    //StyleSheet styleSheet = kit.getStyleSheet();
    FileReader reader = new FileReader("/programs/eclipse/workspace/Planner/src/nl/renepetersconsultancy/planner/gui/HTMLHelp/test.css");
    styleSheet.loadRules(reader, new URL("file:/programs/eclipse/workspace/Planner/src/nl/renepetersconsultancy/planner/gui/HTMLHelp/test.css"));
    kit.setStyleSheet(styleSheet);
    setEditorKit(kit);
    setPage(url);
    I know that the rules are loaded: I printed them to check that. But nothing happens!!!! Almost all layout is gone. If I use the original stylesheet and load my rules on top of them, I can see I have all of them, but everything is layout with the original default style and again my layout is ignored.
    HELP Please, anyone. I am desperate (deadline + demo is tomorrow) :-(
    Rene'

    GL is far easier to do simple CSS than DW, but once you get through the awkward DW interface, it can become clearer. I can only easily see how CSS is created in DW by exporting a GL site that has some already in it. Still not as easy as GL, but we're now stuck with it.
    DW still does not handle full fledged CSS unless you have coding experience.
    DW has always been more for the programmer than designer (just try asking a question on the DW forum :-)
    CS4 seems to be an improvement, but not there yet.

  • JEditorPane with HTML and css

    Hi
    I am trying to display a html file with css (css file is external) in jeditorpane. I managed to display html but css effect is lost. Can anyone help please?

    I do not believe there is currently an html renderer in java that can handle style sheets. Your best bet if you need this is to try to contact a professional java web browser producer like ICESoft

  • Using a CSS in a JEditorPane

    I'm trying to display html pages inside of a JEditorPane using a CSS. I've got some lines of code but I'm not sure which are needed. Here's what I have.
    htmlPane.setEditable(false);
         htmlPane.setContentType("text/html");
         HTMLEditorKit kit = new HTMLEditorKit();
         kit.setStyleSheet(getStyles());
    HTMLDocument htmlDoc = (HTMLDocument)kit.createDefaultDocument();
         htmlPane.setEditorKit(kit);
         htmlPane.setDocument(htmlDoc);
    getStyles() points to my .css file.
    Now how do I display the page? Do I use htmlPane.setPage(), setText(), read(), or something else? If i'm supposed to use htmlDoc how do I add content to that?
    I need to display an xml file formatted nicely without the tags. Any help or advice would be greatly appreciated.
    Thanks

    Hi Elad,
    For JSPs to access this css file here is the sample code. Make sure that you keep your css file inside dist->css folder.
    <Html>
    <Head>
    <%@ page import="com.sapportals.portal.prt.component.IPortalComponentResponse"%>
    <%@ page import="com.sapportals.portal.prt.resource.IResource"%>
    <%
    IPortalComponentResponse componentResponse =
        (IPortalComponentResponse)pageContext.getAttribute(javax.servlet.jsp.PageContext.RESPONSE);
    IResource suckerfishCss = componentRequest.getResource(IResource.CSS, "css/GlobalReportStyles.css");
    componentResponse.include(componentRequest, suckerfishCss);
    %>
    </Head>
    <body>
    </body>
    </html>
    Now the class files must be availble to you.
    Regards,
    Vishal

  • JEditorPane not rendering the CSS

    Hi,
    I am trying to convert a html page to an image by writing the page in a JEditorPane.
    It is rendering the text but not the CSS/images.
    Help me incase anyone know the solution for this issue .
    Thanks,

    This seems helpful: http://forums.sun.com/thread.jspa?messageID=1817077

  • CSS changes ignored in JEditorPane in Java 1.4?

    Our application uses a standard JEditorPane with a content type of text/html to render some HTML files containing tables. These are automatically generated with XSLT and include some stylesheet information to switch the colours of alternating rows in the table so as to make the tables easier to read.
    In Java 1.3. this worked fine. However, I am in the process of porting the application to Java 1.4 and I find that the some of the style changes are being ignored.
    Take this example:
    <html>
    <head>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Test</title>
    <style type="text/css">
         TABLE { font-size: 9px; font-family: verdana,arial,helvetica; color: green }
         tr.Header { background: #1955aa; color: white; font-weight: bold }
         tr { color: blue; background: white }
    tr.AltData { color: red; background: #eeeeee }
    </style>
    </head>
    <body marginheight="0" leftmargin="5" topmargin="10">
    <h2>Table A202</h2>
    <table cellspacing="0" cellpadding="2" border="1" width="90%">
    <tr class="Header">
    <td>Name</td><td>Type</td><td>Scope</td>
    </tr>
    <tr class="AltData">
    <td>0 Formatted</td><td>Text</td><td>Local</td>
    </tr>
    <tr>
    <td>0 Text</td><td>Text</td><td>Global</td>
    </tr>
    <tr class="AltData">
    <td>Channel</td><td>Text</td><td>Local</td>
    </tr>
    <tr>
    <td>CTable</td><td>Table</td><td>Global</td>
    </tr>
    </table>
    </body>
    </html>
    The standard white background, blue text style assigned to all table rows works fine. But attempting to change the style to 'AltData' on alternate rows (using class="AltData") is ignored.
    Java 1.3 does this correctly, Java 1.4 doesn't. Is there a problem with the HTML? Has something changed that I don't know about? Has anyone seen anything similar and can offer a solution? Switching to a third-party control is not an option, by the way.
    Thanks in advance.

    set the style sheet in the in and HTMLEditorKit and then add the kit to the JEditorPane
    We do some thing simple like this here...
    HTMLEditorKit htmlKit = new HTMLEditorKit();
              StyleSheet ss = htmlKit.getStyleSheet();
              ss.addRule("body {font-family : Verdana;}");
              ss.addRule("td {font-size : 10;}");
              HTMLDisplayer = new JEditorPane(this);   //new JEditorPane();
              HTMLDisplayer.setEditorKit(htmlKit);
              HTMLDisplayer.setContentType("text/html");
              HTMLDisplayer.setEditable(false);
              HTMLDisplayer.setVisible(false);

  • Does JEditorPane support JavaScript, CSS, XHTML, HTML?

    Can anyone confirm what JEditorPane actually can support? I can't find anything specific in the J6SE release notes and most of the stuff of Google is pretty dated, I have also searched the forums but nothing much on there that is recent. According to one post it supports some CSS and HTML but no JavaScript.
    Can anyone confirm this?
    What I plan to do is make a lightweight split pane editor for the above but I also want to be able to preview the code in another pane instead of launching a browser. If there still is no support then can anyone suggest an alternative way to get the same results?
    Failing that I will just have to try and then fall back to the browser but it would be nice to know before hand. The online docs I read don't cover a lot on compatibility.
    Cheers

    the answer is no. the html support in JEditorPane is
    very simple to be able to do things like simple help
    manuals and such. But you may be able to integrate
    the mozilla gecko engine into your application if you
    really want this.
    http://jrex.mozdev.org/
    Hi Gimbal,
    Thanks for the info. The jrex thing certainly looks more like what I am after.
    Cheers

  • JEditorPane, CSS, HTML problem

    Hi,
    I am using setEditorKit(new HTMLEditorKit()) with a JEditorPane to render / display a HTML file. The HTML has a stylesheet with it.
    The HTML file has a table in it. When I try to use the CSS values of
    TABLE.black-border { border-width:1px;
                         border-color:black;
                         border-collapse: collapse;
    tr.bb-test { border-width:1px;
                 border-color:black;
                 border-style:solid;
                 border-collapse: collapse;
    td.bb-medium { border-collapse: collapse;
                   border-width:1px;
                   border-color:black;
    <TABLE class=black-border WIDTH=100%>
    <TR>
    <TD class=bb-medium WIDTH=10%>TEST</TD>
    <TD class=bb-medium WIDTH=25%>TEST Number</TD>
    <TD class=bb-medium WIDTH=55%>POLICY Range</TD>
    <TD class=bb-medium WIDTH=10%>DEST DATE</TD>
    </TR>
    <TR class=bb-test>
    <TD class=bb-medium COLSPAN=4>item 1</TD>
    </TR>
    <TR class=bb-test>
    <TD class=bb-medium COLSPAN=4>item 2</TD>
    </TR>
    </TABLE>No matter what I set the border-width to (1, 10, 100), it always comes out as a thick border (same size). But in a web browser, 1, 10 or 100px border looks correct.
    When I try to set the individual borders (i.e. border-top-width ), the JEditorPane shows no border at all (as if it is invalid keyword).
    Does anybody know what the problem is? Any help would be appreciated.
    Thanks
    Roger...

    Better use JTextPane ,where it supports CSS to some extends.
    (I have used in my case for rendering font size and font face).Try to
    use external stylesheet instead of internal ones. Here I paste some part of the code.
              kit = new HTMLEditorKit();//kit s ur HTMLEditorKit
              doc = (HTMLDocument) (kit.createDefaultDocument());
              this.setEditorKit(kit);//'this' is ur JTextPane object
              this.setDocument(doc);
              this.setContentType("text/html");
              css = kit.getStyleSheet();//css s the StyleSheet object
              css.addRule("body {align : left }");//replace this part by ur CSS attributes for Table rendering
              css.addRule("body {font-size : 14pt; }");
              css.addRule("body {font-family : Sans Serif; }");
              css.addRule("div {margin-top: -20pt; }");
              css.addRule("div {margin-bottom: -20pt; }");Let me know weather this works out.

  • How to apply CSS to a JEditorPane?

    Hi all,
    I am working on report displaying and printing.
    the report is in HTML format.
    if the font size on the screen is acceptable, the result of printing font size appears to be too big.
    i want to apply different CSS for displaying and printing.
    where should i get start from, is there any tutorial? or anyone can show me some demo codes?
    thank you.

    You can use "style class" or "inline style" properties to achieve this.
    For both properties you can use EL or managed bean.
    For example:
    inlineStyle="#{bindings.YourField.inputValue == 'something' ? 'color:red;' : 'color:blue;'}"
    styleClass="#{bindings.YourField.inputValue == 'something' ? 'style1' : 'style2'}"
    Dario

  • How to change the color for HTML words in JEditorPane?

    Hi Sir,
    In the JTextPane , we could change the word's color by using:
    Style style = doc.addStyle("test",null);
    StyleConstants.setForeground(style, Color.red);
    doc.setCharacterAttributes(10,20,syle,true);
    we can change the text into red color,which range is from 10 to 30.
    But how to change the color for HTML words in JEditorPane?

    Hi,
    you can use an AttributeSet to apply the foreground color. Let's say, doc is a HTMLDocument, then SimpleAttributeSet set = new SimpleAttributeSet();
    doc.getStyleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, "#0D0D0D"); would apply a color to a given AttributeSet. The AttributeSet with your color then can be applied to a selected range of text in a JEditorPane by   /**
       * set the attributes for a given editor. If a range of
       * text is selected, the attributes are applied to the selection.
       * If nothing is selected, the input attributes of the given
       * editor are set thus applying the given attributes to future
       * inputs.
       * @param editor  the editor pane to apply the attributes to
       * @param a  the set of attributes to apply
      public void applyAttributes(JEditorPane editor, AttributeSet a) {
        ((HTMLDocument) editor.getDocument()).getStyleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, "#0D0D0D");
        editor.requestFocus();
        int start = editor.getSelectionStart();
        int end = editor.getSelectionEnd();
        if(end != start) {
          doc.setCharacterAttributes(start, end - start, a, false);
        else {
          MutableAttributeSet inputAttributes =
            ((SHTMLEditorKit) editor.getEditorKit()).getInputAttributes();
          inputAttributes.addAttributes(a);
      } Ulrich

  • Cascading Style Sheets in JEditorPane..

    I have created a Java program that displays an HTML page in a JEditorPane. The JEditorPane seems to have a problem displaying pages with internal Cascading Style Sheets. The app grabs an HTML file off my and displays it in the JEditorPane but the file does not display correctly. I have tested it with sites that use external Style Sheets and it seems to work fine.
    Does anyone know anything about this?
    Thanks, Jason

    Hi Jason,
    you could try to explicitly set the style sheet to one you pick by the following sample
          StyleSheet ss = getStyleSheet("style.css");
          HTMLEditorKit editorKit = new HTMLEditorKit();
          editorKit.setStyleSheet(ss);
          hd = (HTMLDocument) editorKit.createDefaultDocument(ss);method 'getStyleSheet' looks as follows
      private StyleSheet getStyleSheet(File cssFile)
            throws MalformedURLException, IOException
        StyleSheet ss = null;
        URL cssUrl = cssFile.toURL();
        BufferedReader br = new BufferedReader(
            new InputStreamReader(cssUrl.openStream()));
        ss = new StyleSheet();
        ss.loadRules(br, cssUrl);
        br.close();
        return ss;
      }hope this heps
    Ulrich

Maybe you are looking for