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

1.4.0 REGRESSION: HTML CLASS tag ignored using HTMLEditorKit

XMLWordPrintable

    • 5.0
    • x86
    • windows_nt, windows_2000

      Name: gm110360 Date: 04/25/2002


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

      FULL OPERATING SYSTEM VERSION : Windows NT Version 4.0 SP6


      A DESCRIPTION OF THE PROBLEM :
      I try to display an HTML file with StyleSheets in a
      JEditorPane using an HTMLEditorKit. No matter what kind of
      StyleSheet I use (external or included in the HEAD
      section), the CLASS tag seems to be ignored, i.e.

      <P CLASS="myStyle">sometext<P>

      does not work. The problem only appears with JDK 1.4.0,
      with 1.3.1 everything worked fine.

      This is a serious problem because e.g. existing JavaHelp
      systems that use StyleSheets won't display in the desired
      way anymore.

      REGRESSION. Last worked in version 1.3.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create an HTML file with a STYLE section in the HEAD.
      2. Try to use the defined style element in a CLASS tag.
      3. Display the HTML file in a JEditorPane.
      4. Try this with both JDK 1.3.1 and 1.4.0

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Using JDK 1.3.1 everything works fine. 1.4.0 seems to
      ignore the CLASS tag.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.text.*;

      public class StyleTest {

          public StyleTest() {
          }

          public static void main(String[] args) {

              StringBuffer buf = new StringBuffer();
              buf.append("<HTML>");
              buf.append("<HEAD>");
              buf.append("<STYLE>");
              buf.append(".myStyle { font-size: 8pt ; text-align: center; }");
              buf.append("</STYLE>");
              buf.append("</HEAD>");
              buf.append("<BODY >");
              buf.append("This is the normal font.");
              buf.append("<P CLASS=\"myStyle\">");
              buf.append("This should be very small and centered.");
              buf.append("</P>");
              buf.append("</BODY>");
              buf.append("</HTML>");

              String file = buf.toString();

              JEditorPane pane = new JEditorPane();
              DefaultEditorKit kit = new javax.swing.text.html.HTMLEditorKit();
              pane.setEditorKit(kit);
              StringReader sr = new StringReader(file);
              try {
                  pane.read(sr, null);
              } catch (IOException ex) {
              }

              JFrame frame = new JFrame();
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                      System.exit(0);
                  }
              });
              frame.setSize(new Dimension(640, 480));
              frame.getContentPane().add(pane, BorderLayout.CENTER);
              frame.show();

          }
      }

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

      CUSTOMER WORKAROUND :
      If you want to use styles with JDK 1.4.0 you can use the
      STYLE tag, i.e.

      <P STYLE="font-size: 8pt ; text-align: center;">sometext</P>

      but this is usually not the desired way.

      Release Regression From : 1.3.1_03
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Review ID: 139851)
      ======================================================================
      ###@###.### 10/20/04 18:16 GMT

            idk Igor Kushnirskiy (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: