My TableView
is populated with data from a list of objects. The first column is a Boolean value.
Instead of displaying True
or False
in the cell, I would like to display an image if True
and leave the cell empty if it's False
.
This is how I populate the TableView
:
colStarred.setCellValueFactory(new PropertyValueFactory<>("starred"));
colDate.setCellValueFactory(new PropertyValueFactory<>("date"));
colTime.setCellValueFactory(new PropertyValueFactory<>("time"));
I know that I need to use a custom TableCell
and a CellValueFactory
but I'm having a hard time wrapping my head around the documentation (I have not used Java factories in the past).
My research has lead to several answers regarding similar situations, but they all seem to deal with just displaying an image in the cell. I have been unable to find a solution for checking a boolean to determine whether an image should be displayed or not.
How do I check the starredProperty
of my objects and show an image if it is True
?
Thank you for all the help everyone has provided me in the past!