JavaFX: How to refresh table?

Try tableView.refresh(). It's available in JavaFX since Java 8u60.


Here is a little trick i discovered a year ago...

myTableView.getColumns().get(0).setVisible(false);
myTableView.getColumns().get(0).setVisible(true);

This might not be the best way, but it works for me...


Probably no longer relevant, but simply add

else { setStyle(null) }

to the updateItem method in your custom factory - what's happening is that only as many cells are created as are absolutely required to show on the screen (prevents creating unnecessarily many UI elements). These cells are re-used when you scroll through the table by their updateItem method. Sometimes (in your case), an existing cell will be updated with null to indicate the cell should be empty. You haven't implemented this case, but you should, and you should clear the cell's style.

Tags:

Java

Javafx