Is it possible to filter JTable in a worker thread?

112 views Asked by At

I have a JTable with around 11000 rows and a search box used for filtering on regex. My code in the search box looks like this:

getDocument().addDocumentListener(new DocumentListener()
    {
        public void insertUpdate(DocumentEvent e)
        {
            final RowFilter<TableModel, Object> rf;
            try
            {
                rf = RowFilter.regexFilter(getText(), 0);
            }
            catch (java.util.regex.PatternSyntaxException exception)
            {
                logger.info("Failed to compile regex.", exception);
                return;
            }
            sorter.setRowFilter(rf);   
        } 
        .......

The problem is that the whole UI becomes unresponsive during the filtering operation. I suppose that this is because the filtering is done in the EventDispatchThread so is there a way to somehow put the filtering in a worker thread?

0

There are 0 answers