I have TableView
with 5 TableColumn
. One of these columns represent color of culture on the map.
colorColumn.setCellValueFactory(cellData -> {
return new SimpleObjectProperty<Culture>(cellData.getValue());
});
colorColumn
.setCellFactory(value -> {
CellShape<Rectangle, Culture> elem = new CellShape<Rectangle, Culture>(
new Rectangle(50.0, 30.0, COLOR_OF_APPROPRIATE_CULTURE));
elem.setAlignment(Pos.CENTER);
return elem;
});
Here COLOR_OF_APPROPRIATE_CULTURE
- it is color that is set in Culture
object.
public class Culture
{
private Color color;
//setter and getter
}
So, how to get this color field in CellFactory
?
CellShape
? Is it aTableCell
subclass? – Titulary