Question

I should want to implement a search functionality in a JTextPane. I already use swingx, and I see Searchable interface, with a JXEditorPane.DocumentSearchable. I suppose it's for JXEditorPane.

But I use a JTextPane. Is there some exemple with that ?

Thanks.

Was it helpful?

Solution

If you want to reuse the search components provided by SwingX (for example the JXFindBar) for your JTextPane it is sufficient to create an implementation of the Searchable interface which works against your JTextPane. This Searchable instance can then be passed to the JXFindBar.

The JXEditorPane.DocumentSearchable is more or less what you want since it works against a Document (see source code) so starting from this source code you should have your own implementation ready in a jiffy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top