Check if you "override" all methods of DocumentFilter in the way you need. At least in the method replace(...)
I noticed that you missed the int length
parameter. I suggest to change it to:
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String string, AttributeSet attr){
System.out.print("replace invoked");
try {
super.insertString(fb, offset, "; You inserted the string: "+string, attr);
} catch (BadLocationException e) {
e.printStackTrace();
}
}