All pastes #779108 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-11-18 05:34 UTC
rendered paste body
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);
}