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

JEditorPane does not work correctly with wrong type of content

XMLWordPrintable

    • 1.2.2
    • sparc
    • solaris_2.5.1



      Name: akC57697 Date: 12/17/98



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

        The javax.swing.JEditorPane c-tor throws NullPointerException
       if mime type of the content is wrong.

      The javadoc says:
      public JEditorPane(String type,
                         String text)

          Creates a JEditorPane that has been initialized to the given text.
          This is a convenience constructor that
          calls the setContentType and setText methods.
          Parameters:
             type - mime type of the given text.
             text - the text to initialize with.

      public final void setContentType(String type)

          Sets the type of content that this editor handles. This calls
          getEditorKitForContentType, and then setEditorKit if an editor <--
          kit can be successfully located. This is mostly convenience
          method that can be used as an alternative to calling setEditorKit
          directly.

          If there is a charset definition specified as a parameter of the
          content type specification, it will be used when loading input
          streams using the associated EditorKit.
          ...
          Parameters:
             type - the non-null mime type for the content editing support.



      The example:
      -------------------------------------------------------------
      public class Test {
        public static void main(String[] argv) {
            javax.swing.JEditorPane object =
             new javax.swing.JEditorPane("unknown/unknown", "The text");
         }
      }
      -------------------------------------------------------------

      Output:
      java full version "JDK-1.2.2-A"
      java -Djava.compiler=NONE Test

      java.lang.NullPointerException
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:124)
      at javax.swing.JEditorPane.createEditorKitForContentType(JEditorPane.java:855)
      at javax.swing.JEditorPane.getEditorKitForContentType(JEditorPane.java:747)
      at javax.swing.JEditorPane.setContentType(JEditorPane.java:645)
      at javax.swing.JEditorPane.<init>(JEditorPane.java:198)
      at Test.main(Test.java:4)

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

            tprinzing Tim Prinzing (Inactive)
            akuzminorcl Alexander Kuzmin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: