1
我使用JEditorPane在java中創建編輯器。我已經設法使用熒光筆創建查找功能的功能。我想爲它添加替換功能.. thnx。在JEditorPane中查找並替換
我使用JEditorPane在java中創建編輯器。我已經設法使用熒光筆創建查找功能的功能。我想爲它添加替換功能.. thnx。在JEditorPane中查找並替換
我覺得你應該去通過
Document doc = editorPane.getDocument();
// remove the text you want to replace
doc.remove(startingOffset, length);
// add replacement
doc.insertString(startingOffset, newText, attributes);
當然,你需要知道在哪裏要替換的開始和有多長文..
如何通過在屬性參數 – 2010-11-09 12:45:10
他們文字的屬性(顏色,風格等等),無論如何都與你的問題無關http://download.oracle.com/javase/6/docs/api/javax/swing/text/AttributeSet.html – Jack 2010-11-09 12:59:03