[英]How can I react to JEditorPane text changes?
I'm working to build an editor. 我正在建立一个编辑器。 I'd like to know whether the text in JEditorPane
is modified or not. 我想知道JEditorPane
的文本是否被修改。 How can I react to editor pane text changes? 如何对编辑器窗格的文本更改做出反应?
The following code seems not work. 以下代码似乎不起作用。
JEditorPane editorConfig = new JEditorPane();
editorConfig.getDocument().addDocumentListener(new DocumentListener(){
@Override
public void insertUpdate(DocumentEvent e) {
System.out.println("insertUpdate called");
Dialogc.this.refreshTitle();
}
@Override
public void removeUpdate(DocumentEvent e) {
System.out.println("removeUpdate called");
Dialogc.this.refreshTitle();
}
@Override
public void changedUpdate(DocumentEvent e) {
System.out.println("changedUpdate");
Dialogc.this.refreshTitle();
}
});
Thanks very much for your feedback; 非常感谢您的反馈; the code is right for document update. 该代码适合文档更新。 The code did not work because the document of JTextArea are changed in the coming logic. 该代码不起作用,因为JTextArea的文档在即将到来的逻辑中已更改。
Thanks Klaus 谢谢克劳斯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.