harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Elford (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3625) [classlib][swing] JTextPane throws java.lang.IllegalArgumentException: Model must be 'StyledDocument'
Date Tue, 24 Apr 2007 00:59:15 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-3625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12491110
] 

Chris Elford commented on HARMONY-3625:
---------------------------------------

I see this same basic problem when trying to run the JFreeChart JNLP Demo using OpenJNLP to
launch it as well.

The specification for javax.swing.JEditorPane.getStream() indicates that it is supposed to
have the "side effect" of establishing the content type (see http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JEditorPane.html#getStream).

Looking at the code for JEditorPane in SVN, its interesting how it loads the stream twice.
 I'm not quite clear how it is following HTML redirects but that is not the problem in Gregory's
test case which just loads a local file.  (Note that I'd think that one would simply use the
URL and get the headerfields for the MIME type rather than reading it by hand from the stream.)

In any case, I'd think that getContentTypeByInputStream for this test would return a PLAIN_CONTENT_TYPE.
 Running in a debugger verifies this.  This appears to allocate a PlainEditorKit in setContentType
which seems to match the specification.  I don't see a very complete description of PlainEditorKit
(other than it being the default wrapper) in the specification of EditorKit but it pretty
clearly indicates that it is not a subclass of a StyledEditor.

Its unclear why Sun and BEA work here and use a StyledEditor for a text/plain file.

I modified the test slightly to confirm that types were resolving as expected:

import javax.swing.*; 

public class Test { 
    public static void main(String[] arg) throws Exception { 
        JFrame frame = new JFrame("Hello"); 
        frame.resize(640,480); 
        JTextPane pane = new JTextPane(); 
        frame.add(pane); 
System.out.println("pref="+pane.getEditorKitClassNameForContentType("text/plain"));
System.out.println("type-before="+pane.getContentType());

        java.net.URL url = Test.class.getResource("Test.java"); 
        pane.setPage(url); 
         

        frame.setVisible(true); 
System.out.println("type-after="+pane.getContentType());
System.out.println("pref="+pane.getEditorKitClassNameForContentType("text/plain"));
System.out.println("kit="+pane.getEditorKit());
    } 
} 


> [classlib][swing] JTextPane throws java.lang.IllegalArgumentException: Model must be
'StyledDocument'
> -----------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3625
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3625
>             Project: Harmony
>          Issue Type: Bug
>          Components: App-Oriented Bug Reports, Classlib
>            Reporter: Mikhail Fursov
>
> Here is the test:
> import javax.swing.*;
> public class Test {
>     public static void main(String[] arg) throws Exception {
>         JFrame frame = new JFrame("Hello");
>         frame.resize(640,480);
>         JTextPane pane = new JTextPane();
>         frame.add(pane);
>         java.net.URL url = Test.class.getResource("Test.java");
>         pane.setPage(url);
>         
>         frame.setVisible(true);
>     }
> }
> It runs OK on SUN or BEA but fails on Harmony with 
> Uncaught exception in main:
> java.lang.IllegalArgumentException: Model must be 'StyledDocument'
>         at javax.swing.JTextPane.setDocument(JTextPane.java:72)
>         at javax.swing.JEditorPane.updateDocument(JEditorPane.java:610)
>         at javax.swing.JEditorPane.setContentType(JEditorPane.java:577)
>         at javax.swing.JEditorPane.getStream(JEditorPane.java:464)
>         at javax.swing.JEditorPane.setPage(JEditorPane.java:700)
>         at Test.main(Test.java:11)
> error.
> This problem is a blocker for JFreeChart demo when run on Harmony.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message