Using DocumentFilter.FilterBypass

前端 未结 2 744
盖世英雄少女心
盖世英雄少女心 2020-12-02 01:06

I want to have a method like this on my DocumentFilter

public void replaceUpdate(int offset, int length, String text) {
        try {
                   


        
2条回答
  •  失恋的感觉
    2020-12-02 01:40

    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);
    }
    

提交回复
热议问题