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

Swing HTML table with omitted closing tags misparsed

XMLWordPrintable

    • b21
    • 20
    • b27
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Linux x64

      A DESCRIPTION OF THE PROBLEM :
      The test case shows a Swing JLabel with a two-column HTML table (from a generated file list item tooltip). The closing tags of HTML <tr> <th> <td> elements are optional by the spec, and here they are omitted. Java 6 thru 19 have never given me grief about omitted tags. Testing in JDK 20 EA Build 22, the table is completely mangled unless I add the closing tags.

      REGRESSION : Last worked in version 19.0.1


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

      class SwingHtmlTable {
          SwingHtmlTable() {
              try {
                  UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
              } catch (Exception e) {
                  throw new RuntimeException(e);
              }
              
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              
              String html = "<html><table>" +
                  "<tr><th align=right>Name:<td>sync-001.mp4" +
                  "<tr><th align=right>Modified:<td>2017-Jul-31, 00:14:55" +
                  "<tr><th align=right>File size:<td>3.1 MB" +
                  "<tr><th align=right>Duration:<td>1m03s" +
                  "<tr><th align=right>Video:<td>854 x 480 - 16:9 - 30.0 fps - 271 kbps - H.264 / AVC" +
                  "<tr><th align=right>Audio:<td>Stereo - 44100 Hz - 123 kbps - AAC";
              
              JLabel label = new JLabel(html);
              
              frame.add(label);
              
              frame.pack();
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
          }
          
          public static void main(String... args) {
              SwingUtilities.invokeLater(SwingHtmlTable::new);
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        1. Capture.PNG
          15 kB
          Praveen Narayanaswamy
        2. SwingHtmlTable.java
          1 kB
          Praveen Narayanaswamy

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: