आखिरकार यह वही काम करता है।
JTextArea
here के स्रोत कोड पर जाएं, जहां आप पाते हैं कि यह वही काम कर रहा है। आप कहां मिल सकता है कि यह फोन करने के मामले में
d.remove(pos, word1.length());
d.insertString(pos, word2.toUpperCase(), null);
कर रहा है मैं यहाँ भी विधि की नकल की है:
t.replaceRange(word2.toUpperCase(), pos, pos+ word1.length());
विधि। वर्ग की विधि की
स्रोत कोड के नीचे
public void replaceRange(String str, int start, int end) {
490 if (end < start) {
491 throw new IllegalArgumentException ("end before start");
492 }
493 Document doc = getDocument();
494 if (doc != null) {
495 try {
496 if (doc instanceof AbstractDocument) {
497 ((AbstractDocument)doc).replace(start, end - start, str,
498 null);
499 }
500 else {
501 doc.remove(start, end - start);
502 doc.insertString(start, str, null);
503 }
504 } catch (BadLocationException e) {
505 throw new IllegalArgumentException (e.getMessage());
506 }
507 }
508 }
स्रोत
2012-05-12 08:23:35
उत्सुक: क्यों बक्षीस? क्या आप अपने उत्तर से खुश नहीं हैं? – kleopatra