JDK-4813831 : HTML in JEditorPane - contents of table cells do not wrap correctly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-02-06
  • Updated: 2003-09-26
  • Resolved: 2003-09-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Relates :  
Relates :  
Relates :  
Description

Name: jk109818			Date: 02/05/2003


FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
There seems to be five problems related to HTML display:

1. Text in the cells doesn't wrap properly when the available display area is smaller than the table and creates blank lines after the longest lines.

2. The window size is not being calculated correctly when packed, evidenced by the reall tall window that is empty at the bottom.

3. There is a blank line at the bottom of the cells that shouldn't be there.

4. When centered, the last line in the cell doesn't line up with the ones above it.

5. The string of '|' (pipe) characters should not wrap.  Only white space should allow strings of characters to wrap.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. compile example below
2. run example
3. resize window smaller than the table
4. observe the strange wrapping behavior

EXPECTED VERSUS ACTUAL BEHAVIOR :
If you save the HTML source below into a file and open it in a modern browser like Internet Explorer 6 and compare the wrapping behavior to my Java example.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;

public class TestDialog extends JDialog {
  JPanel panel1 = new JPanel();
  JScrollPane jScrollPane1 = new JScrollPane();
  JTextPane jTextPane1 = new JTextPane();
  
  String content =
    "<html><head>" +
    "</head><body>" +
    "<table border><tr>" +
    "<td>X<BR>XXXXX XXXXX<BR>X<BR>X<BR></td>" +
    "<td align=center>I<BR>IIIIIIIIIIIIII<BR>I<BR>I</td>" +
    "<td align=center>|<BR>||||||||||||||<BR>|<BR>|</td>" +
    "</tr></table>" +
    "</body></html>";
  
  public TestDialog() {
    super((Frame)null, "", true);
    jTextPane1.setContentType("text/html");
    jTextPane1.setText(content);
    jTextPane1.setEditable(false);
    this.setModal(true);
    this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
    jScrollPane1.getViewport().add(jTextPane1, null);
  }
  
  public static void main(String[] args) {
    JDialog dlg = new TestDialog();
    dlg.pack();
    dlg.show();
    System.exit(0);
  }
  
}


/* HTML SOURCE FOR COMPARISON IN WEB BROWSERS

<html><head>
</head><body>
<table border><tr>
<td>X<BR>XXXXX XXXXX<BR>X<BR>X<BR></td>
<td align=center>I<BR>IIIIIIIIIIIIII<BR>I<BR>I</td>
<td align=center>|<BR>||||||||||||||<BR>|<BR>|</td>
</tr></table>
</body></html>

*/

---------- END SOURCE ----------
(Review ID: 179306) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b22
14-06-2004

EVALUATION Name: ik75403 Date: 02/07/2003 It is too late to fix it for mantis. Whill do for the next release. ====================================================================== Name: dsR10138 Date: 07/07/2003 Issues 1,2 and 3 are well known. They exist due to extra newline added to the end of each paragraph. Similar bug is 4623342 which need to be fixed. Issue 4 appears because BRView has non-zero span which is incorrect. This needs to be fixed. Issue 5. We use BreakIterator's word instance in Inline view to find the word with the longest span (method getLongestWordSpan()). BreakIterator assumes that symbols like '|', ',', '.', etc. are not part of a word, so a line may be broken at any of such symbols. This issue will not be fixed. ###@###.### 2003-07-07 ====================================================================== Name: dsR10138 Date: 07/15/2003 Currently BRView is placed to a single row. if we have html code "<TD>AAA<BR>BBB</TD>" then there will be 3 rows of text in a paragraph: AAA <BR> BBB Setting BRView's span to 0 would solve such a problem, but in case there were several sequient BRs like <TD>AAA<BR><BR><BR><BR><BR><BR>BBB</TD> there would be no vertical gap between AAA and BBB. There would be AAA BBB instead of: AAA BBB So instead of setting BRView's span to 0 row layout policy needs to be changed. ###@###.### 2003-07-15 ======================================================================
15-07-2003