Reputation: 37
I'm programming with a library that I don't know the code, only the methods, and I can't modify it. I tried to make a tableview of "flights" and it works but I don't know how to put a name(or ID) for each fly. Can someone help me? Thanks. Some code here:
public class StageController {
@FXML private TableView<Flight> flightsTable;
@FXML private TableColumn<Flight, String> flightColumn;
public void start(Airport air){
final AirportFlights a = Data.getInstance().getAirportFlights(air);
ObservableList<Flight> flights = FXCollections.observableArrayList(a.getArrivals().getFlights().values());
flightsTable.setItems(flights);
}
Upvotes: 0
Views: 966
Reputation: 36792
You need to declare a valueFactory
for your tablecolumn. If you have a field name
inside your Flight
class then, you can do :
flightColumn.setCellValueFactory(
new PropertyValueFactory<Flight, String>("name"));
Upvotes: 1