JavaFX 8: how to add a timedelay to a listener?

前端 未结 2 1971
故里飘歌
故里飘歌 2020-12-06 21:46

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

2条回答
  •  长情又很酷
    2020-12-06 22:09

    Interesting problem, and one which I'm sure others have dealt with. I'm thinking this through for the first time and don't know how practical this suggestion is, but here goes:

    Have your text field listeners send a notification to a queue. Then, use a util.TimerTask method that executes at your preferred time interval to process the queue, and use that to build a new filter (or not).

    The wait time in the above could be rather varied, so to make it a bit more consistent, send the text field ID with a time stamp and have the Timer run more frequently and only process the new filter if a certain amount of time has elapsed.

    There are various concurrency-safe queues that could be used to house the data.

提交回复
热议问题