I want to have a method like this on my DocumentFilter
DocumentFilter
public void replaceUpdate(int offset, int length, String text) { try {
I liked @hovercraft's solution, but it gave me concurrency issues. I solved this by synchronizing the filter toggling on the text area. Like this:
synchronized (textArea) { myDocFilter.setFilter(false); textArea.append("12345\n"); myDocFilter.setFilter(true); }