How to know what text has been deleted from a JTextPane
===

I have added a document listener to a JTextPane.  I want to know what text has been added or removed so I can take action if certain key words are entered.  The insert part works just fine, but I do not know how to detect what text was deleted.

The insert works because the text is there and I can select it, but the delete has already removed the text so I get bad location exceptions sometimes.  

I want to make reserved words that are not inside quotes bold so I need to know what has been removed, removing even one character (like a quote) could have a huge impact.

My code follows:

    	@Override
	public void insertUpdate(DocumentEvent e)
	{
		Document doc = e.getDocument();
		String i = ""; 
		
		try
		{
			i = doc.getText(e.getOffset(), e.getLength());
		}
		catch(BadLocationException e1)
		{
			e1.printStackTrace();
		}
		
		System.out.println("INSERT:" + e + ":" + i);
	}

	@Override
	public void removeUpdate(DocumentEvent e)
	{
		Document doc = e.getDocument();
		String i = ""; 
		
		try
		{
			i = doc.getText(e.getOffset(), e.getLength());
		}
		catch(BadLocationException e1)
		{
			e1.printStackTrace();
		}
		
		System.out.println("REMOVE:" + e + ":" + i);
	}
