JavaFX - How To Process TableView Change Before Continuing Code?

32 Views Asked by At

I have a TableView whose data is refreshed when the user clicks a button. However, the database query used to get the data can take some time.

During the search, I wish to display the TableView's placeholder (which is a ProgressIndicator:

// Add progress indicator while searching
ProgressIndicator pi = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS);
pi.setMaxHeight(tblCallRecordList.getHeight() / 2);
tblCallRecordList.setPlaceholder(pi);

// Clear the table data
searchResults.clear();
tblCallRecordList.setItems(searchResults);

// Run the new search
processSearch();

However, when running the program, the TableView is never changed and the processSearch() method runs right away, keeping the old data in the TableView until the search is completed.

If I comment out processSearch(), the placeholder is displayed just fine.

Is there some strange thread flow going on that I am missing?

0

There are 0 best solutions below