重写 JTextArea.getDocument.remove()?

发布于 2024-09-27 18:19:03 字数 137 浏览 0 评论 0原文

好吧,我想重写JTextArea的Document的remove方法,我不知道要扩展哪个类。我无法扩展 Document 因为它是一个接口,这也意味着它不能是 JTextArea 创建的文档。那么我到底如何才能轻松地重写 JTextArea 文档的删除方法呢?

Okay, I want to override JTextArea's Document's remove method, I can't figure out what class to extend. I can't extend Document cause it's a interface, and that also means it must not be the document that JTextArea creates. So how exactly can I easily override my JTextArea's document's remove method?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月牙弯弯 2024-10-04 18:19:04

The default Document of a JTextArea is PlainDocument, as mentioned in createDefaultModel(). Here is a simple example of overriding insertString() in PlainDocument.

冷月断魂刀 2024-10-04 18:19:04

尝试使用 DocumentFilter 代替。

Try to use DocumentFilter instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文