public void append(String toAppend) {
try {
getDocument().insertString(getText().length(), toAppend, null);
}
catch (BadLocationException exception) {
/* This shouldn't happen in theory -- but, if it does... */
throw new RuntimeException("Unexpected exception occurred.", exception);
}
}
public void insertString(int offset, String text, AttributeSet attributes) throws BadLocationException {
// Just return when no text to insert was given.
if (text == null || text.length() == 0)
return;
DefaultDocumentEvent event = new DefaultDocumentEvent(offset, text.length(), DocumentEvent.EventType.INSERT);
content.insertString(offset, text);
insertUpdate(event, attributes);
fireInsertUpdate(event);
}