doc.remove(start, end - start);
doc.remove(p0, p1 - p0);
  public void replaceSelection(String content)  {    Caret caret = getCaret();    StyledDocument doc = getStyledDocument();    int dot = caret.getDot();    int mark = caret.getMark();    // If content is empty delete selection.    if (content == null)      {	caret.setDot(dot);	return;      }    try      {	int start = getSelectionStart();	int end = getSelectionEnd();	int contentLength = content.length();	// Remove selected text.	if (dot != mark)	  doc.remove(start, end - start);	// Insert new text.	doc.insertString(start, content, null);	// Set attributes for inserted text	doc.setCharacterAttributes(start, contentLength, getInputAttributes(),				   true);      }    catch (BadLocationException e)      {	throw new AssertionError	  ("No BadLocationException should be thrown here");      }  }