// Make sure this event is a document event
if (edit instanceof DefaultDocumentEvent) {
// Get the event type
DefaultDocumentEvent event = (DefaultDocumentEvent) edit;
EventType eventType = event.getType();
// Check if the event type is not a change on character attributes, but instead an insertion or removal of
// text.
if (eventType != EventType.CHANGE) {
boolean isEndCompoundEdit = false;