Rendering HTML Table borders in JEditorPane

Discussion in 'Java' started by Jason Cavett, Oct 8, 2007.

  1. Jason Cavett

    Jason Cavett Guest

    I'm using a JEditorPane to render HTML for the purposes of printing.
    It works very well except I cannot render borders for tables. I
    haven't been able to find any bugs in the Sun bug database related to
    this issue and I'm wondering if I'm just doing something wrong. I've
    tried using both styles (AKA border-width: 3px;) and just <table
    border=3>.

    A normal browser renders the tables correctly in both cases.


    Thanks for any help/advice you can give.
     
    Jason Cavett, Oct 8, 2007
    #1
    1. Advertising

  2. Jason Cavett wrote:
    >I'm using a JEditorPane to render HTML for the purposes of printing.
    >It works very well except I cannot render borders for tables. I
    >haven't been able to find any bugs in the Sun bug database related to
    >this issue and I'm wondering if I'm just doing something wrong. I've
    >tried using both styles (AKA border-width: 3px;) and just <table
    >border=3>.


    That HTML is not well-formed. Try this instead:

    <html>
    <body>
    <table border='3'>
    <tr>
    <td>R1-C1</td>
    <td>R1-C2</td>
    </tr>
    <tr>
    <td>R2-C1</td>
    <td>R2-C2</td>
    </tr>
    </table>
    </body>
    </html>


    >A normal browser ..


    What is 'a normal browser'? I am not sure what that
    means 'in your neck o' the woods', but I feel quite
    confident in saying that JEditorPane is no 'normal
    browser - it is no kind of browser at all'. All it is
    good for, is rendering simple, valid (well-formed)
    HTML controlled by you.

    >..renders the tables correctly in both cases.


    At one time, 50% of the enormous code of IE
    was said to be for correcting crappy HTML. I
    would not be surprised if 20-40%+ of the code of
    other major UAs is much the same. JEP has
    none (or close enough to say as much) of that.

    >Thanks for any help/advice you can give.


    Validate, validate, validate. Then KISS.

    --
    Andrew Thompson
    http://www.athompson.info/andrew/

    Message posted via http://www.javakb.com
     
    Andrew Thompson, Oct 8, 2007
    #2
    1. Advertising

  3. Jason Cavett

    Jason Cavett Guest

    On Oct 8, 1:07 pm, "Andrew Thompson" <u32984@uwe> wrote:
    > Jason Cavett wrote:
    > >I'm using a JEditorPane to render HTML for the purposes of printing.
    > >It works very well except I cannot render borders for tables. I
    > >haven't been able to find any bugs in the Sun bug database related to
    > >this issue and I'm wondering if I'm just doing something wrong. I've
    > >tried using both styles (AKA border-width: 3px;) and just <table
    > >border=3>.

    >
    > That HTML is not well-formed. Try this instead:
    >
    > <html>
    > <body>
    > <table border='3'>
    > <tr>
    > <td>R1-C1</td>
    > <td>R1-C2</td>
    > </tr>
    > <tr>
    > <td>R2-C1</td>
    > <td>R2-C2</td>
    > </tr>
    > </table>
    > </body>
    > </html>
    >
    > >A normal browser ..

    >
    > What is 'a normal browser'? I am not sure what that
    > means 'in your neck o' the woods', but I feel quite
    > confident in saying that JEditorPane is no 'normal
    > browser - it is no kind of browser at all'. All it is
    > good for, is rendering simple, valid (well-formed)
    > HTML controlled by you.
    >
    > >..renders the tables correctly in both cases.

    >
    > At one time, 50% of the enormous code of IE
    > was said to be for correcting crappy HTML. I
    > would not be surprised if 20-40%+ of the code of
    > other major UAs is much the same. JEP has
    > none (or close enough to say as much) of that.
    >
    > >Thanks for any help/advice you can give.

    >
    > Validate, validate, validate. Then KISS.
    >
    > --
    > Andrew Thompsonhttp://www.athompson.info/andrew/
    >
    > Message posted viahttp://www.javakb.com


    1. Not sure what HTML you're talking about? I didn't really post any
    in my message other than the <table> tag and I wasn't going for well-
    formed. I was just showing what I had tried. When I actually write
    my application I use well-formed, full HTML (per your example).

    2. Normal browser = IE, Firefox, Safari - the three I tested. Yes, I
    realize a JEditorPane is not a browser but since I'm only concerned
    about rendering HTML, it's all the same thing at the moment.

    3. Okay...well...either way IE *does* render the table. JEP does
    not. I'm wondering if this is an actual problem or if there is
    something I completely missed (which, it doesn't appear I have since
    all the other HTML renders correctly).

    4. Not sure what you mean by validate. And, the HTML is as simple as
    you can get - just one table.
     
    Jason Cavett, Oct 9, 2007
    #3
  4. Jason Cavett

    Lew Guest

    Jason Cavett wrote:
    > 4. Not sure what you mean by validate.


    Presumably to submit the HTML to
    <http://validator.w3.org/>

    --
    Lew
     
    Lew, Oct 9, 2007
    #4
  5. Jason Cavett wrote:
    >> >I'm using a JEditorPane to render HTML for the purposes of printing.
    >> >It works very well except I cannot render borders for tables.

    ...
    >1. Not sure what HTML you're talking about? I didn't really post any
    >in my message other than the <table> tag ...


    Yes that* - let's move on..

    >3. Okay...well...either way IE *does* render the table. JEP does
    >not. ...


    Huhh.

    I tried that exact HTML above, in a JEP using
    Java 1.6. Here is a screenshot of the result.
    <http://www.physci.org/test/screenshot/tableborderinjep.png>
    That looks like a border to me. Are you seeing
    something different on your system?

    >4. Not sure what you mean by validate. ...


    * I am relatively (narrowly) focused on validation
    at the moment. ;-)

    --
    Andrew Thompson
    http://www.athompson.info/andrew/

    Message posted via JavaKB.com
    http://www.javakb.com/Uwe/Forums.aspx/java-general/200710/1
     
    Andrew Thompson, Oct 9, 2007
    #5
  6. Jason Cavett

    Jason Cavett Guest

    On Oct 9, 10:22 am, "Andrew Thompson" <u32984@uwe> wrote:
    > Jason Cavett wrote:
    > >> >I'm using a JEditorPane to render HTML for the purposes of printing.
    > >> >It works very well except I cannot render borders for tables.

    > ..
    > >1. Not sure what HTML you're talking about? I didn't really post any
    > >in my message other than the <table> tag ...

    >
    > Yes that* - let's move on..
    >
    > >3. Okay...well...either way IE *does* render the table. JEP does
    > >not. ...

    >
    > Huhh.
    >
    > I tried that exact HTML above, in a JEP using
    > Java 1.6. Here is a screenshot of the result.
    > <http://www.physci.org/test/screenshot/tableborderinjep.png>
    > That looks like a border to me. Are you seeing
    > something different on your system?
    >
    > >4. Not sure what you mean by validate. ...

    >
    > * I am relatively (narrowly) focused on validation
    > at the moment. ;-)
    >
    > --
    > Andrew Thompsonhttp://www.athompson.info/andrew/
    >
    > Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200710/1


    Well, I'm using Java 5 (forgot to mention that) so if it works on 6,
    that won't help.

    Either way, I think I'm not going to worry about it. The customer
    likes how it looks as is.
     
    Jason Cavett, Oct 9, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lee
    Replies:
    7
    Views:
    605
  2. Romano Signorelli
    Replies:
    0
    Views:
    686
    Romano Signorelli
    Jul 31, 2003
  3. Robin
    Replies:
    0
    Views:
    727
    Robin
    May 12, 2005
  4. George
    Replies:
    9
    Views:
    4,973
    George
    Oct 25, 2004
  5. weight watcher
    Replies:
    4
    Views:
    439
    Jonathan N. Little
    Jun 24, 2005
Loading...

Share This Page