Java 将包含图像的RTF加载到JTextPane

Java 将包含图像的RTF加载到JTextPane,java,rtf,jtextpane,Java,Rtf,Jtextpane,我想将包含图像和文本的RTF文件加载到JTextPane。 问题是只发送文本而不发送图像 以下是我尝试过的: private static final RTFEditorKit RTF_KIT = new RTFEditorKit(); (...) text.setContentType("text/rtf"); inputStream = new FileInputStream(filename); DefaultStyledDocument style

我想将包含图像和文本的RTF文件加载到JTextPane。 问题是只发送文本而不发送图像

以下是我尝试过的:

    private static final RTFEditorKit RTF_KIT = new RTFEditorKit();
    (...)
    text.setContentType("text/rtf");
    inputStream = new FileInputStream(filename);
    DefaultStyledDocument styledDocument = new DefaultStyledDocument(new StyleContext());
    RTF_KIT.read(inputStream, styledDocument, 0);
    text.setDocument(styledDocument);

是的,我知道还有其他类似的问题,我没有在任何问题中找到答案,谢谢。

尝试使用setEditorKit将rtfeditorkit设置为JTextPane,然后使用getDocument而不是创建styledDocument。尝试其他方法谢谢各位,我将尝试高级方法。