Rendering HTML Table borders in JEditorPane

J

Jason Cavett

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.
 
A

Andrew Thompson

Jason said:
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>
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.
 
J

Jason Cavett

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>


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.


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.


Validate, validate, validate. Then KISS.

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.
 
A

Andrew Thompson

Jason said:
...
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
 
J

Jason Cavett

Yes that* - let's move on..


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?


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

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,002
Messages
2,570,258
Members
46,858
Latest member
FlorrieTuf

Latest Threads

Top