我们如何知道与documentEvent中的文档关联的JeditorPane

时间:2016-04-02 12:59:30

标签: java swing text jeditorpane

为了在桌面java应用程序中链接文本块,我继承了JEditorPane来创建块文本。我的问题是在 documentEvent 中我需要检索与关联的 JEditorPane 相关的信息。但我不明白在documentEvent和JEditorPane之间建立联系的方法。 感谢您的帮助

1 个答案:

答案 0 :(得分:1)

没办法。文件只是一个模型。可以将同一文档实例设置为多个JEditorPanes。

jEditlorPane2.setDocument(jEditlorPane1.getDocument())

您可以获取所有存在的JEditorPane实例的列表,并遍历列表,检查Document实例是否等于jEditorPaneInstance.getDocument()