Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4212722

Swing JEditorPane + HTMLEditorKit bombs on complex layouts

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.1.7, 1.3.0
    • client-libs
    • generic, x86, sparc
    • generic, solaris_2.6, solaris_7, windows_95, windows_98



      Name: gsC80088 Date: 02/18/99


      When you use a JEditorPane with HTMLEditorKit to render HTML,
      the HTMLEditorKit generates non-fatal NullPointerExceptions and
      fails to render the document if it contains complex nested tables.

      An example is developer.netscape.com.

      I am using this component in a mail reader to read HTML email
      messages generated from Berkeley-style mail folders. Very simple
      layouts work, but fairly complex ones don't.
      (Review ID: 52431)
      ======================================================================

      Name: krT82822 Date: 05/05/99


      I am developing an e-mail application that uses a JEditorPane to display the incoming messages. I am using the Swing 1.1.1 beta.
      I have come across some formatting issues particularly with tables.

      Below is some HTML from a recent message (unfortunately its kind of spammy) that shows this pretty well. To view it, you can use the TextSamplerDemo application and replace the code in TextSamplerDemoHelp.htm with it. You may also want to increase the preferred size of the JEditorPane on line 93 of TextSamplerDemo.java to something like (600, 500) to make viewing easier.

      Viewing this same file in IE4.0 or Navigator 4.0 shows it is as expected.

      <HTML>
      <HEAD>
        <META NAME="GENERATOR" CONTENT="Adobe PageMill 3.0 Win">
        <TITLE>Untitled Document</TITLE>
      </HEAD>
      <BODY BGCOLOR="#ffffff">

      <P><TABLE WIDTH="522" BORDER="0" CELLSPACING="2" CELLPADDING="2">
        <TR>
          <TD WIDTH="90%" VALIGN="TOP" BGCOLOR="#ffffc6">
          <TABLE WIDTH="502" BORDER="3" CELLSPACING="2" CELLPADDING="2">
            <TR>
              <TD WIDTH="75%" VALIGN="TOP">
              <P><CENTER><B><FONT SIZE="+2" FACE="Arial"><IMG SRC="http://www.datamerge.com/loanpackager/cd.jpg"
              WIDTH="70" HEIGHT="50" ALIGN="MIDDLE" BORDER="0" NATURALSIZEFLAG="0"><BR
              CLEAR="ALL">Top Quality Loan Proposals</FONT></B></CENTER></P>

              <P><CENTER><B><FONT SIZE="+2" FACE="Arial">In A Fraction Of The
              Time!</FONT></B></CENTER></P>

              <P><CENTER><A HREF="http://www.datamerge.com/loanpackager/loanpackager.html"><FONT
               FACE="Arial">Loan Packager Software</FONT></A><FONT FACE="Arial"><BR
              CLEAR="ALL">For Commercial Real Estate:</FONT></CENTER></P>

              <BLOCKQUOTE>
                <P><CENTER><TABLE WIDTH="233" BORDER="2" CELLSPACING="2" CELLPADDING="2">
                  <TR>
                    <TD WIDTH="100%">
                    <P><CENTER><I><FONT SIZE="+2">&nbsp;</FONT><FONT COLOR="#ff0000"
                     SIZE="+1">Your deal gets looked at first and financed fast!</FONT></I></CENTER></TD>
                  </TR>
                </TABLE></CENTER></P>
                <P><CENTER>Call 800-580-1188</CENTER></P>
                <P><B><FONT SIZE="-1" FACE="Arial">Save Time.</FONT></B><FONT
                 SIZE="-1" FACE="Arial"> Prequalify, package and submit your
                deals in hours, not weeks.</FONT></P>
                <P><B><FONT SIZE="-1" FACE="Arial">All Inclusive.</FONT></B><FONT
                 SIZE="-1" FACE="Arial"> The only &quot;start to finish&quot;
                loan packaging system ... every form, report and calculation
                a lender will ever request.</FONT></P>
                <P><B><FONT SIZE="-1" FACE="Arial">Get Financed First.</FONT></B><FONT
                 SIZE="-1" FACE="Arial"> Superior quality loan proposals lenders
                will look at first.</FONT></P>
                <P><B><FONT SIZE="-1" FACE="Arial">Teaches You Commercial. </FONT></B><FONT
                 SIZE="-1" FACE="Arial">Built in knowledgebase .. shows you how
                to close every type of deal.</FONT></P>
                <P><B><FONT SIZE="-1" FACE="Arial">Generates Dealflow.</FONT></B><FONT
                 SIZE="-1" FACE="Arial"> Sample adds, intro letters and contracts
                pull in projects, with time tested results.</FONT></P>
              </BLOCKQUOTE>

              <P><CENTER><B><FONT COLOR="#ff0000" FACE="Arial">Get it today
              and start closing tomorrow!<HR></FONT></B></CENTER></TD>
              <TD WIDTH="120" BGCOLOR="#ffffff" VALIGN="TOP" ALIGN="CENTER">
              <P><TABLE WIDTH="28%" BORDER="5" CELLSPACING="5" CELLPADDING="2"
              HEIGHT="239">
                <CAPTION ALIGN="TOP"><B><FONT COLOR="#ff0000">MODULES</FONT></B></CAPTION>

                <TR>
                  <TD WIDTH="167" BGCOLOR="#cccccc" HEIGHT="23">
                  <P><CENTER><B><FONT SIZE="-2" FACE="Arial"><A HREF="http://www.datamerge.com/loanpackager/dealflow.html">DEALFLOW</A></FONT></B></CENTER></TD>
                </TR>
                <TR>
                  <TD WIDTH="167" BGCOLOR="#cccccc" HEIGHT="23">
                  <P><CENTER><B><FONT SIZE="-2" FACE="Arial"><A HREF="http://www.datamerge.com/loanpackager/loanprequal.html">PREQUAL</A></FONT></B></CENTER></TD>
                </TR>
                <TR>
                  <TD WIDTH="167" BGCOLOR="#cccccc" HEIGHT="23">
                  <P><CENTER><B><FONT SIZE="-2" FACE="Arial"><A HREF="http://www.datamerge.com/loanpackager/loaninquiry.html">LOAN
                  INQUIRY</A></FONT></B></CENTER></TD>
                </TR>
                <TR>
                  <TD WIDTH="167" BGCOLOR="#cccccc" HEIGHT="23">
                  <P><CENTER><A HREF="http://www.datamerge.com/loanpackager/loananalysis.html"><FONT
                   SIZE="-2">&nbsp;</FONT><B><FONT SIZE="-2" FACE="Arial">ANALYSIS</FONT></B></A></CENTER></TD>
                </TR>
                <TR>
                  <TD WIDTH="167" BGCOLOR="#cccccc" HEIGHT="23">
                  <P><CENTER><A HREF="http://www.datamerge.com/loanpackager/loanpackaging.html"><FONT
                   SIZE="-2">&nbsp;</FONT><B><FONT SIZE="-2" FACE="Arial">PACKAGING</FONT></B></A></CENTER></TD>
                </TR>
                <TR>
                  <TD WIDTH="167" BGCOLOR="#cccccc" HEIGHT="23">
                  <P><CENTER><B><FONT SIZE="-2" FACE="Arial"><A HREF="http://www.datamerge.com/loanpackager/loanpresentation.html">PRESENTATION</A></FONT></B></CENTER></TD>
                </TR>
                <TR>
                  <TD WIDTH="167" BGCOLOR="#cccccc" HEIGHT="23">
                  <P><CENTER><B><FONT SIZE="-2" FACE="Arial"><A HREF="http://www.datamerge.com/loanpackager/loanorder.html">Order</A></FONT></B></CENTER></TD>
                </TR>
              </TABLE><BR CLEAR="ALL"><FONT SIZE="-1" FACE="Arial">For faxed
              information and samples:</FONT></P>

              <P><FONT SIZE="-1" FACE="Arial">Call DataMerge, Inc. 800-580-1188</FONT></P>

              <P><FONT SIZE="-1" FACE="Arial">Or Click Here:</FONT></P>

              <P><A HREF="http://www.datamerge.com/forms/info.html"><B><FONT
               SIZE="+1" FACE="Arial"> More Info</FONT></B></A><FONT SIZE="-1"
               FACE="Arial"><BR CLEAR="ALL"><BR CLEAR="ALL"></FONT><TABLE
              WIDTH="105" BORDER="0" CELLSPACING="1" CELLPADDING="1" HEIGHT="172">
                <TR>
                  <TD WIDTH="100%" BGCOLOR="#dfdfdf" VALIGN="TOP">
                  <P><CENTER><FONT COLOR="#ff0000" FACE="Arial">New:</FONT><FONT
                   COLOR="#ff0000" SIZE="-1" FACE="Arial"> </FONT><FONT SIZE="-1"
                   FACE="Arial">Submit your loan packages electronically to lenders.
                  Click here for:<BR CLEAR="ALL"><A HREF="http://www.financingsources.com/">Electronic
                  Loan Submission System</A></FONT></CENTER></TD>
                </TR>
              </TABLE></TD>
            </TR>
          </TABLE></TD>
        </TR>
      </TABLE><TABLE WIDTH="100%" BORDER="0" CELLSPACING="2" CELLPADDING="2"
      HEIGHT="54">
        <TR>
          <TD WIDTH="100%" VALIGN="TOP" HEIGHT="49">
          <A HREF="http://www.datamerge.com/maps/foot.map?281,2"><IMG
          SRC="http://www.datamerge.com/loanpackager/foot.gif" ALIGN="BOTTOM"
          BORDER="0"></A></TD>
        </TR>
      </TABLE></P>

      <P></CENTER>

      </BODY>
      </HTML>


      </BODY></HTML>
      (Review ID: 57842)
      ======================================================================

      Name: skT88420 Date: 07/01/99


      I have a problem displaying a HTML table (a table in a table)
      in JEditorPane using swing1.1.1beta3/jdk1.1.7a.

      Here is the java code to reproduce the problem.

      ---------------------start--------------------------
      import javax.swing.*;
      import java.net.*;
      import java.io.*;

      public class HTMLTableTest extends JApplet {

      public void init () {

      try {
      URL url = new URL(getCodeBase().toString() + "sample.html");
      editor = new JEditorPane(url);
      }
      catch (MalformedURLException mue) {
      System.out.println("malformedURLException :: " + mue.getMessage());
      }
            catch (IOException ioe) {
               System.out.println("IOException :: " + ioe.getMessage());
            }

      getContentPane().add(editor);
      }//init

         private JEditorPane editor;
      }
      ---------------------end----------------------------

      Here is the sample HTML file with a embeded table.
      NOTE : Save this HTML file as sample.html

      --------------------------start----------------------
      <HTML>
      <table border = 1>
      <tr>
         <td BGcolor = "#ffffcc">&nbsp;</td>
         <td BGcolor = "#ffffcc">Scores</td>
      </tr>

      <tr>
         <td BGcolor = "#ffffcc">Criteria</td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">
         
         <table border = 1><tr>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc"><b><I>Criteria / Scores</I></b></td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc"><b>Getting Started</b></td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc"><b>Not Yet</b></td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc"><b>Got it</b></td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc"><b>Wow!</b></td>
      </tr>

      <tr>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc"><b>Consumes in timely manner</b></td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">Takes over an hour to consume or is still eating</td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">finished bagel in less than 15 minutes&nbsp;</td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">finished bagel in 5 minutes or less&nbsp;</td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">finished bagel in 3 minutes or less&nbsp;</td>
      </tr>

      <tr>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc"><b>Consumes bagel quota of one whole bagel</b></td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">consumes 2 bites or less of bagel&nbsp;</td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">consumes at least 50% of bagel but leaves leftovers or large crumbs on table&nbsp;</td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">eats entire bagel leaves no crumbs&nbsp;</td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">eats entire bagel leaves no crumbs and eats the leftovers from others&nbsp;</td>
      </tr>

      <tr>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc"><b>exhibits gratitude for bagel</b></td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">is obviously disdainful of bagels&nbsp;</td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">eats bagel but without relish&nbsp;</td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">eats happily and hums a tune&nbsp;</td>
         <td align="left" VAlign = "Top" width = "400" BGcolor = "#ffffcc">eats happily, then gets us and dances&nbsp;</td>
      </tr>

      </table></td>
      </tr></table>

      </HTML>
      --------------------------end-----------------------

      Finally, this is the HTML page to load the applet
      ---------------------start-------------------------
      <HTML>
      <APPLET code="HTMLTableTest.class" WIDTH=300 HEIGHT=250>
      </APPLET>
      </HTML>
      --------------------------end-----------------------

      To observe :

      The sample.html file contains html code to create a table
      within a table cell. But, when this table is displayed in
      the JEditorPane, the inner table does not fit into the cell
      of the outer table. It projects out. Also, though the width
      of each column is specified in the html code, the JEditorPane
      seems to ignore it.

      ###@###.###
      (Review ID: 54549)
      ======================================================================

            idk Igor Kushnirskiy (Inactive)
            gstone Greg Stone
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: