开发者

Swing - Search text within a JTextField

开发者 https://www.devze.com 2023-02-25 18:28 出处:网络
I have a documents that\'s displayed in a non-editable JTextField , and I want to enable users to search within this document.

I have a documents that's displayed in a non-editable JTextField , and I want to enable users to search within this document.

I already figured out I could use a custom JTextField for input , and use the HighLight painter to mark the occurrences - But I couldn't help but feeling that this seems like such a common problem that maybe there's a component that does it much bett开发者_如何学Pythoner then I can (like cycling through the results, highlighting them in different colors , ignoring case...)

Do you know of any such thing?


SwingX comes with complete search support (in a JEditorPane only, sigh: note to myself - how about the other text components?)


The Swing book (by Matthew Robinson and Pavel Vorobiev) has a great chapter on Constructing an HTML Editor Application which shows you how you can implement "Find and Replace".

0

精彩评论

暂无评论...
验证码 换一张
取 消