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

swing.text.html.MinimalHTMLWriter.writeNonHTMLAttributes does not work correctly

XMLWordPrintable

    • 1.2.2
    • sparc
    • solaris_2.5.1



      Name: akC57697 Date: 01/22/99


      This bug was found by St.Petersburg Java SQE team (by Sergey Scherbakov).

        The method javax.swing.text.html.MinimalHTMLWriter.writeNonHTMLAttributes(attr)
       writes out incorrect color component.

      The example:
      -------------------------------------------------------------
      import javax.swing.text.html.*;
      import javax.swing.text.*;
      import java.io.*;
      import java.awt.*;

      public class Test {

          public static void main(String argv[]) {

              String test="<HTML><BODY>test</BODY></HTML>";

              HTMLEditorKit c = new HTMLEditorKit();
              HTMLDocument doc = new HTMLDocument();

              try {
                  c.read(new StringReader(test),doc,0);
              } catch (Exception e1) {
                  System.out.println("Unexpected "+e1);
              }

              StringWriter sw = new StringWriter();
              StubMinimalHTMLWriter hw = new StubMinimalHTMLWriter(sw, doc);

              SimpleAttributeSet attr = new SimpleAttributeSet();
              attr.addAttribute(StyleConstants.Foreground, Color.red);
              attr.addAttribute(StyleConstants.FontSize, new Integer(14));
              attr.addAttribute(StyleConstants.FontFamily, "Times");

              try {
                  hw.writeNonHTMLAttributes(attr);
              } catch (Exception e1) {
                  System.out.println("Unexpected "+e1);
              }

              System.out.println(sw.toString());
          }
      }

      class StubMinimalHTMLWriter extends MinimalHTMLWriter {
          StubMinimalHTMLWriter(Writer w, StyledDocument doc) {
              super(w, doc);
          }

          public void writeNonHTMLAttributes(AttributeSet attr)
              throws IOException {
              super.writeNonHTMLAttributes(attr);
          }
      }

      -------------------------------------------------------------

      Output:
      <font style="color: java.awt.Color[r=255,g=0,b=0]; font-size: 14;
      font-family: Times; ">

      ======================================================================

            svioletsunw Scott Violet (Inactive)
            akuzminorcl Alexander Kuzmin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: