I am trying to display a ChoiceBox inside of a TableView in JavaFX. Right now I am just trying to test if I can get this working, so I am generating fake data within the cell fa
ChoiceBoxTableCell.forTableColumn(...)
returns a Callback
itself (i.e. it returns the cellFactory
, not the cell).
You can just do
ObservableList testlist = FXCollections.observableArrayList("A", "B", "C");
guiSpecifierColumn.setCellFactory(ChoiceBoxTableCell.forTableColumn(testlist));
If you are implementing the factory yourself, its call(...)
method needs to return the actual cell. In this case you would just construct a ChoiceBoxTableCell
directly and return it:
guiSpecifierColumn.setCellFactory(
new Callback, TableCell>() {
@Override
public TableCell call(TableColumn param) {
ObservableList testlist = FXCollections.observableArrayList("A", "B", "C");
return new ChoiceBoxTableCell(testlist);
}
});