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?