void (int begin, int end, String s) { myText = myText.replace(begin, end, s); myReplacements.add(new Replacement(begin, end, s)); if (myCaretOffset == end) { myCaretOffset += s.length() - (end - begin); } }