super.setDocument(doc);
if (doc != null) {
doc.addDocumentListener(docListener);
if (doc instanceof StyledDocument) {
StyledDocument sd = (StyledDocument) doc;
Style style = sd.getStyle(StyleContext.DEFAULT_STYLE);
StyleConstants.setFontFamily(style, "SansSerif");
attrNormal = style;
attrAddedLocally = sd.addStyle(STYLE_ADDED_LOCALLY, attrNormal);
StyleConstants.setForeground(attrAddedLocally, Color.BLUE);
StyleConstants.setBold(attrAddedLocally, true);
attrAddedByOther = sd.addStyle(STYLE_ADDED_BY_OTHER, attrNormal);
StyleConstants.setForeground(attrAddedByOther, Color.RED);
StyleConstants.setBold(attrAddedByOther, true);
attrRemovedByOther = sd.addStyle(STYLE_REMOVED_BY_OTHER, attrNormal);
StyleConstants.setForeground(attrRemovedByOther, Color.RED);
StyleConstants.setStrikeThrough(attrRemovedByOther, true);
StyleConstants.setBold(attrRemovedByOther, true);
attrRemovedLocally = sd.addStyle(STYLE_REMOVED_LOCALLY, attrNormal);
StyleConstants.setForeground(attrRemovedLocally, Color.BLUE);
StyleConstants.setStrikeThrough(attrRemovedLocally, true);
StyleConstants.setBold(attrRemovedLocally, true);
}
}