title: Remove last character from JTextPane
body: <p>I'm writing a vt100 emulator and I'm using a JTextPane with a DefaultStyledDocument to display the formatted text. Now I want to implement the backspace, so i need to be able to remove the last character. </p>
  
  <p>I tried the following:</p>
  
  <pre><code>doc.remove(doc.getEndPosition().getOffset()-1, doc.getEndPosition().getOffset());
  </code></pre>
  
  <p>But I keep getting a 'javax.swing.text.BadLocationException: Invalid remove'</p>
  
  <p>How should this be done?</p>