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".
精彩评论