С или без javax.swing.text.Document

Учитывая, что

JTextArea t = new JTextArea();
Document d = t.getDocument();
String word1 = "someWord";
String word2 = "otherWord"
int pos = t.getText().indexOf(word1,i);

В чем разница между ...
это

if(pos!= -1){
    t.replaceRange(word2.toUpperCase(), pos, pos+ word1.length());
}

и это

if(pos!= -1){
    d.remove(pos, word1.length());
    d.insertString(pos, word2.toUpperCase(), null);
}
5
задан Jazz 12 May 2012 в 08:29
поделиться