I'm making a program to manage and show data about airports, their flights and so on. The fact is that I have a tableView (in javafx) with several tableColumns, and I want to show some information (destiny, origin, company, etc) on each column so I typed this:
@FXML
private TableColumn<Flight, String> destinoCol;
@FXML
private TableColumn<Flight, String> numCol;
@FXML
private MenuButton aeropuerto;
@FXML
private MenuButton tipo;
@FXML
private Button filtrar;
@FXML
private TableColumn<Flight, LocalTime> horaCol;
@FXML
private Button este;
@FXML
private DatePicker fecha;
@FXML
private TableColumn<Flight, String> origenCol;
@FXML
private Label retrasoLabel;
@FXML
private ImageView companiaImg;
@FXML
private VBox detalles;
@FXML
private Button todos;
@FXML
private ImageView avionImg;
@FXML
private Label tipoLabel;
private mainVuelos m;
private List<Airport> aeropuertos;
private Data data;
@FXML
void initialize() {
data = Data.getInstance();
aeropuertos = data.getAirportList();
List<MenuItem> ItemAeropuertos = new LinkedList<MenuItem>();
for (int i = 0; i < aeropuertos.size(); i++) {
MenuItem item = new MenuItem(aeropuertos.get(i).getName());
item.setOnAction((event) -> cambiarAer(event));
ItemAeropuertos.add(item);
}
aeropuerto.getItems().setAll(ItemAeropuertos);
destinoCol.setCellValueFactory(cellData -> cellData.getValue().getDestiny());
}
The method getDestiny()
, as it says returns the destiny of a specific flight as a String
so obviously I cannot use the last instruction, it says
cannot convert from String to ObservableValue<String>
but I don't really know how to solve it in order to be able to show the destinies on that column.