Handling TableView Cell Data - eviltoast

After finishing the TableView Basics article, I thought it was a good idea to keep on going with the next logical TableView topic: how to handle data coming into your TableCells.

I think it’s best if you view a TableCell just the same way you would any other layout. In other words, create a static layout that behaves dynamically in response to changes in the underlying data model. This is conceptually a little bit more complicated with TableCell because that data model is constantly replaced with new versions of the data model as the TableView is populated and the users scroll through it.

Usually, you don’t see this complexity because you have a data model for the TableCell that’s just a single value. But if you want to have a single column column in your TableView show data from several different elements in your TableView data model, or if you want to have TableCells that display data from a more complicated TableCell data model, then you need to have a better understanding about how that data moves in and out of your TableCells.

Along the way, this article looks at Cell.updateItem() and finds that it’s pretty heavily abused and misused - not just in random “how to” articles on the web, but in the JavaFX JavaDocs as well.

Take a look at Handling TableCell Data if you’re interested.