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

JEditorPane throws NullPointerException when reloaded

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.6.0_22"
      Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
      Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)

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

      A DESCRIPTION OF THE PROBLEM :
      When I re-load the applet, the JEditorPane throws a NullPointerException.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run applet in IE or AppletViewer, and reload.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      JEditorPane do not throw a NullPointerException
      ACTUAL -
      JEditorPane throws a NullPointerException.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.NullPointerException
              at javax.swing.text.html.parser.Parser.errorContext(Parser.java:736)
              at javax.swing.text.html.parser.Parser.parse(Parser.java:2240)
              at javax.swing.text.html.parser.DocumentParser.parse(DocumentParser.java:105)
              at javax.swing.text.html.parser.ParserDelegator.parse(ParserDelegator.java:78)
              at javax.swing.text.html.HTMLEditorKit.read(HTMLEditorKit.java:232)
              at javax.swing.JEditorPane.setText(JEditorPane.java:1499)
              at javax.swing.JEditorPane.<init>(JEditorPane.java:273)
              at sample.SampleApplet.start(SampleApplet.java:22)
              at sun.applet.AppletPanel.run(AppletPanel.java:464)
              at java.lang.Thread.run(Thread.java:662)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      -------------------------
      Java source
      -------------------------
      package sample;

      import javax.swing.JApplet;
      import javax.swing.JEditorPane;
      import javax.swing.text.html.parser.ParserDelegator;

      /**
       * <applet code="sample.SampleApplet.class" width="150" height="150"></applet>
       */
      public class SampleApplet extends JApplet {

          {
              System.out.println("initialize");
          }

          public void start() {
              System.out.println("start");
              String html = "<html><body>test</body></html>";
              JEditorPane.registerEditorKitForContentType("text/html", "javax.swing.text.html.HTMLEditorKit");

              try {
                  JEditorPane htmlPane = new JEditorPane("text/html", html);
              } catch(RuntimeException e) {
                  e.printStackTrace();
              }
          }
      }


      -------------------------
      HTML for IE
      -------------------------
      <html><body>
      <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="150" height="150">
      <param name="code" value="sample.SampleApplet.class">
      </object>
      </body></html>

      -------------------------
      HTML for AppletViewer
      -------------------------
      <applet code="sample.SampleApplet.class" width="150" height="150">
      </applet>


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

            rupashka Pavel Porvatov (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: