Reputation: 1371
I would like to create a TableView
. In my .fxml
controller, I have these two columns:
@FXML
private TableColumn<Log, String> planeRegistrationColumn;
@FXML
private TableColumn<Log, String> planeTypeColumn;
The log class has an attribute Plane
which is a Plane instance. But the setCellValueFactory
doesn't seem to like it:
planeRegistrationColumn.setCellValueFactory(cellData -> cellData.getValue().planeProperty().get().getRegistration());
getRegistration()
returns a String, but it needs an ObservableValue<String>
. Is it a conception problem? And if not, how to can I do this?
Upvotes: 1
Views: 6797
Reputation: 209225
Just wrap the string you get in some kind of observable value:
planeRegistrationColumn.setCellValueFactory(cellData ->
new SimpleStringProperty(cellData.getValue().planeProperty().get().getRegistration()));
Upvotes: 2