Results 1 to 5 of 5
  1. #1
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default HTML and CSS in JEditorPane.setPage

    Hi, I am trying to create a HTML help file and load it in Editor pane but it only show the texts but do not follow the
    css code inside the html file

    Here is the HTML file code:
    Java Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <style type="text/css">
            ul  {   list-style-type:none;
                    margin:0;
                    padding:0;
                }
    
            li  {   display:inline;   }
        </style>
    
          <title></title>
      </head>
    
      <body bgcolor = "rgb('102,102,102')">
          <div style="width:400px;; background:#FFFFFF">
              <ul>
                <li>menu 1</li>
                <li>menu 2</li>
                <li>menu 3</li>
                <li>menu 4</li>
              </ul>
          </div>
      </body>
    </html>
    I am trying to load it like this
    Java Code:
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            try
            {   String url = "file:///" + System.getProperty("user.dir") + "\\src\\folder\\Help\\";
                JEditorPane1.setContentType("text/html");
                JEditorPane1.setPage(url + "Help.html");
            }
            catch(Exception ex)
            {   ex.printStackTrace();
            }
        }
    Thanks,
    geje

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,335
    Blog Entries
    7
    Rep Power
    20

    Default

    What happens if you set the content type to "text/html"?

    kind regards,

    Jos

    edit: hrmph, you edited your OP so ignore this reply ...

  3. #3
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    @JosAh: im sorry, i just did not notice that the sample does not have "text/html" but the actual code has a contentType.
    Also, I did not see your reply before I edit it...

    I change
    Java Code:
    <div style="width:400px;; background:#FFFFFF">
    [b]to[/b]
    <div style="width:400px; background:#FFFFFF">
    I also notice that the bullets in lists gone which means that JEditorPane was able to read the css but not
    Java Code:
     li
     {  display: inline;
     }
    Why?


    I have try to run this HTML in google chrome and the output is ok.


    Thanks,
    geje

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,335
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by mine0926 View Post
    @JosAh: im sorry, i just did not notice that the sample does not have "text/html" but the actual code has a contentType.
    Also, I did not see your reply before I edit it...

    I change
    Java Code:
    <div style="width:400px;; background:#FFFFFF">
    [b]to[/b]
    <div style="width:400px; background:#FFFFFF">
    I also notice that the bullets in lists gone which means that JEditorPane was able to read the css but not
    Java Code:
     li
     {  display: inline;
     }
    Why?


    I have try to run this HTML in google chrome and the output is ok.


    Thanks,
    geje
    I don't know much about html (and I like to keep it that way thank you ;-) but note that Java implements html version 3.2. Maybe your constructs are html version 4.0; check it.

    kind regards,

    Jos

  5. #5
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    Thanks. I will check that and will post back for the result.

Similar Threads

  1. Format editing in HTML view with JEditorPane
    By peterme in forum Advanced Java
    Replies: 4
    Last Post: 02-23-2011, 09:05 PM
  2. Replies: 1
    Last Post: 01-22-2010, 05:23 PM
  3. JEditorPane, HTML 4.0, CSS, custom Tags
    By AndreB in forum AWT / Swing
    Replies: 4
    Last Post: 12-22-2009, 10:45 AM
  4. setPage
    By prof.deedee in forum AWT / Swing
    Replies: 5
    Last Post: 11-11-2009, 01:43 AM
  5. jeditorpane help parsing html
    By asifsolkar in forum Advanced Java
    Replies: 4
    Last Post: 12-14-2007, 05:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •