开发者

find and replace in JEditorPane

I am creating an 开发者_Python百科editor in java using JEditorPane. I have managed to create functionality for find function using Highlighters. I want to add replace functionality to it.. thnx.


I think you should go by

Document doc = editorPane.getDocument();

// remove the text you want to replace
doc.remove(startingOffset, length);

// add replacement
doc.insertString(startingOffset, newText, attributes);

Of course you need to know where the text you want to replace starts and how long it is..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜