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

JEditorPane ignores registered EditorKit for text/plain

XMLWordPrintable

    • b14
    • x86
    • windows_xp

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

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

      A DESCRIPTION OF THE PROBLEM :
      When a custom EditorKit is registered for text/plain, a newly instantiated JEditorPane with text/plain content type ignores the registry and uses the default EditorKit as specified by the UI. This is because JEditorPane.setContentType() only changes the EditorKit if the content types differ, which they never do since the UI always creates a text/plain EditorKit for a JEditorPane.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test source.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Registered: javax.swing.text.DefaultEditorKit
      Actual: javax.swing.text.DefaultEditorKit@xxxxxx

      ACTUAL -
      Registered: javax.swing.text.DefaultEditorKit
      Actual: javax.swing.JEditorPane$PlainEditorKit@xxxxxx


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JEditorPane;
      import javax.swing.text.DefaultEditorKit;

      public class BugTest
      {
      public static void main(String[] args)
      {
      JEditorPane.registerEditorKitForContentType("text/plain", DefaultEditorKit.class.getName());
      System.out.println("Registered: " + JEditorPane.getEditorKitClassNameForContentType("text/plain"));

      JEditorPane editorPane = new JEditorPane("text/plain", null);
      System.out.println("Actual: " + editorPane.getEditorKit());
      }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Set the JEditorPane content type to something other than text/plain to force registry lookup, e.g. replace:

      JEditorPane editorPane = new JEditorPane("text/plain", null);

      with:

      JEditorPane editorPane = new JEditorPane();
      editorPane.setContentType("text/rtf");
      editorPane.setContentType("text/plain");
      ###@###.### 11/3/04 20:43 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: