Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2007

Tip: Looking for answers? Try searching our database.

HTML table used in JTextPane not working with cellspacing="0" attribute

Thread view: 
btschumy@gmail.com - 20 Mar 2007 18:23 GMT
In Java 1.6 on Windows, I'm trying to display an HTML table in a
JTextPane where cellspacing="0".  It should display the cell borders
as a single line but it is instead displaying it as if cellspacing was
"1".  Is this a known problem or am I possibly doing something wrong?
I'm tried many variations.  The code below was generated using
Netscape Composer and displays correctly in other browsers.

The file I'm loading is (sorry if the formatting is messed up):

<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Table</title>
</head>
<body>
<table style="text-align: left; width: 100%;" border="1"
cellpadding="2"
cellspacing="0">
<tbody>
<tr>
<td style="vertical-align: top;">Blah<br>
</td>
<td style="vertical-align: top;">val<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">Blah<br>
</td>
<td style="vertical-align: top;">val<br>
</td>
</tr>
</tbody>
</table>
<br>
</body>
</html>
Andrew Thompson - 21 Mar 2007 02:41 GMT
On Mar 21, 4:23 am, btsch...@gmail.com wrote:
> In Java 1.6 on Windows, I'm trying to display an HTML table in a
> JTextPane where cellspacing="0".  It should display the cell borders
> as a single line but it is instead displaying it as if cellspacing was
> "1".  

Interestingly,
1) cellspacing="20" makes a huge space, so it seems
to be honouring that attribute at some level, in some
form.  I suspect that there is some other spacing in
there that the JEditorPane is (in its simplistic styling
of HTML) expecting to see for a true 'no pad' cell.
2) That document is valid HTML 3.2 Transitional!
(Yeah, you probably already knew that, but that is
just the first time anybody that I have seen, has
asked a question about JEP rendering, *and* were using
well-formed HTML - which I thought worthy of note.)

As a piece of general advice:  Remove all style
attributes from HTML and put them in an external
stylesheet, so that they can be validated in a CSS
validator.  (It looks fine to me, but I am not as
accurate as a software validator.)

If I have any further insights into it, I
will pop back by.

Andrew T.
btschumy@gmail.com - 21 Mar 2007 15:19 GMT
> On Mar 21, 4:23 am, btsch...@gmail.com wrote:
>
[quoted text clipped - 14 lines]
>
> Andrew T.

Andrew,

Yes, the cellspacing attribute is being handled, just not correctly.
I actually tried making it -1 and that does cause single pixel lines
to be drawn between cell, but the the border around all the cells is
still not drawn correctly.  I wouldn't want to use this hack in
production code, but it is interesting.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.