436 |
*/ |
*/ |
437 |
public void insert(String string, int position) |
public void insert(String string, int position) |
438 |
{ |
{ |
439 |
// Retrieve the document model. |
// Retrieve the document model. |
440 |
Document document = getDocument(); |
Document doc = getDocument(); |
441 |
|
|
442 |
// Check the model and string for validity. |
// Check the model and string for validity. |
443 |
if (document == null |
if (doc == null |
444 |
|| string == null |
|| string == null |
445 |
|| string.length() == 0) |
|| string.length() == 0) |
446 |
return; |
return; |
447 |
|
|
448 |
// Insert the text into the model. |
// Insert the text into the model. |
449 |
try |
try |
450 |
{ |
{ |
451 |
document.insertString(position, string, null); |
doc.insertString(position, string, null); |
452 |
} |
} |
453 |
catch (BadLocationException exception) |
catch (BadLocationException e) |
454 |
{ |
{ |
455 |
throw new IllegalArgumentException("The supplied position, " |
throw new IllegalArgumentException("The supplied position, " |
456 |
+ position + ", was invalid."); |
+ position + ", was invalid."); |
457 |
} |
} |
458 |
} |
} |
459 |
|
|
460 |
public void replaceRange(String text, int start, int end) |
public void replaceRange(String text, int start, int end) |