I'm working on an JavaFX 8 app right now, where i have a tableView and some textFields above which make it possible to search/filter for certain columns in the tableView. I have added a listener to the textFields, to trigger the filtering automatically when a change is detected. I used the code below to do this.
textField_filterAddress.textProperty().addListener((observable, oldValue, newValue) -> {
doSomething(); // in this case, filter table data and refresh tableView afterwards
});
My question now is: what's the easiest way to integrate some kind of time delay, before the filtering gets triggered? I'd like to wait a few milliseconds, because everytime the user is filtering it's executing a new database query and i don't think this is necessary for every single char that the user puts in. I'd rather wait until he/she finished his input. Is there some kind of feature like this already built into the whole listener thing? Or do i have to implement my own solution? If so, how? I thought about some kind of concurrency solution, so the rest of the software won't freeze during the waiting period. But i thought i'd ask here if there is an easier solution before thinking too much about my own way...
Big thanks in advance!