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<String> 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<TableColumn<RequirementsProperty, String>, TableCell<RequirementsProperty, String>>() {
@Override
public TableCell<RequirementsProperty, String> call(TableColumn<RequirementsProperty, String> param) {
ObservableList<String> testlist = FXCollections.observableArrayList("A", "B", "C");
return new ChoiceBoxTableCell(testlist);
}
});