Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Rendering HTML Table borders in JEditorPane

Reply
Thread Tools

Rendering HTML Table borders in JEditorPane

 
 
Jason Cavett
Guest
Posts: n/a
 
      10-08-2007
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.

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      10-08-2007
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

 
Reply With Quote
 
 
 
 
Jason Cavett
Guest
Posts: n/a
 
      10-09-2007
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.

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      10-09-2007
Jason Cavett wrote:
> 4. Not sure what you mean by validate.


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

--
Lew
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      10-09-2007
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.asp...neral/200710/1

 
Reply With Quote
 
Jason Cavett
Guest
Posts: n/a
 
      10-09-2007
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Div with borders only partially rendering Lee ASP .Net 7 12-06-2005 02:17 PM
Different rendering of cell borders between browsers weight watcher HTML 4 06-24-2005 08:11 PM
JEditorPane (text/html) - determining position of caret in HTML source Robin Java 0 05-12-2005 03:48 PM
Tables with different color left and right borders, no top or bottom borders, etc. George HTML 9 10-25-2004 04:25 PM
JEditorPane: HTML show with simple navigate without mouse Romano Signorelli Java 0 07-31-2003 01:47 PM



Advertisments