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

empty trailing cells removed from table in JTextPane.getText()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6
    • client-libs

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


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Use JTextPane with an HTMLEditorKit and create an HTML table with an empty cell at the end of the table, the last cell will be dropped when the HTML is re-generated. For example, calling JTextPane.getText() will receive an HTML string with last pair of <td> tag missing.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Instantiate JTextPane()
      Give it an HTMLEditorKit()
      Use the setText() method and give HTML with a table that contains an empty cell at the end of the table. E.g.:

      <html>
        <head></head>
        <body>
          <table>
            <tr>
              <td></td>
              <td></td>
            </tr>
            <tr>
              <td></td>
              <td></td>
            </tr>
          </table>
        </body>
      </html>

      When you use the method getText() to retrieve the HTML, the last cell will be missing

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      <html>
        <head>
          
        </head>
        <body>
          <table border="1">
            <tr>
              <td>
                
              </td>
              <td>
                
              </td>
            </tr>
            <tr>
              <td>
                
              </td>
              <td>
                
              </td>
            </tr>
          </table>
        </body>
      </html>
      ACTUAL -
      <html>
        <head>
          
        </head>
        <body>
          <table border="1">
            <tr>
              <td>
                
              </td>
              <td>
                
              </td>
            </tr>
            <tr>
              <td>
                
              </td>
            </tr>
          </table>
        </body>
      </html>

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import javax.swing.text.html.*;

      public class Test {
          public static void main(String[] args) {
              try {
                  JTextPane p = new JTextPane();
                  p.setEditorKit(new HTMLEditorKit());
                  p.setText("<table><tr><td></td><td></td></tr><tr><td></td><td></td></tr></table>");
                  System.out.println(p.getText());
              } catch (Throwable t) {
                  t.printStackTrace();
              }
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None that I'm aware of.

            peterz Peter Zhelezniakov
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: