JEdi​​torPane和自定义编辑器套件

JEdi​​torPane和自定义编辑器套件

本文介绍了JEdi​​torPane和自定义编辑器套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题。我需要使用自定义编辑器工具包将现有文件加载到 JEditorPane 中。
我有一个编辑器工具包,一个带有扩展名的文件,我需要强制 JEditorPane 来识别我的文件并使用我的编辑器工具包。我发现只有,这是可能的,但无处可去。

I've a trivial question. I need to load an existing file into JEditorPane using custom editor kit.I've a editor kit, a file with some extension and I need to force the JEditorPane to recognize my file and use my editor kit. I've found only, that's possibile, but nowhere how.

该工具包也基于HTML和文件。如果文件具有 .html 扩展名,它可以正常工作,但当我将文件重命名为 .xhtbm 时,它会被打开作为纯文本。内容类型设置为 text / plain ,但我无法为此类型注册我的编辑器工具包,因为已经为此内容类型注册了另一个编辑器工具包。

The kit is based on HTML and the file too. If file has the .html extension, it works, but when I rename the file to .xhtbm, it is opened as plain text. The content type is set to text/plain, but I'm unable to register my editor kit for this type, because there is already registered another editor kit for this content type.

实际上问题是:是否真的可以将某些编辑器工具包与某种文件类型相关联?

Actually the question is: Is really possible to associate some editor kit with some file type?

推荐答案

设置你的EditorKit和用户工具包的read()方法在那里传递文件。

Set your EditorKit and user the kit's read() method passing the file there.

read方法中使用的阅读器应该理解如何解析内容。

The reader used in the read method should understand how to parse the content.

这篇关于JEdi​​torPane和自定义编辑器套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:30