I have a tableview with several columns. TableView I fill with objects At an object 2 fields: line and the list

String сar = "Mazda" List carParts; 

There are several other lines in the list, for example "wheels", "engine", "suspension"

The first column is Car.setCellValueFactory(new PropertyValueFactory<>("car")); displays the brand.

How to set the second third and the following columns to take the field from the first list? For example, something like this: the second column is Wheels.setCellValueFactory(new PropertyValueFactory<>(carParts.get(0));

    1 answer 1

    For example, implement your factory:

      carColumn.setCellValueFactory(new Callback<CellDataFeatures<Car, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<Car, String> p) { return new ReadOnlyObjectWrapper(((Car)p.getValue()).getParts.get(0)); } }); 

    Note that this factory provides read-only objects. If you need to monitor the state of a cell for changes by the user, I recommend using Property in the object itself.