Turns out I was switching the scene the wrong way and that caused the buttons to stop working. Changed it thisway and now it works.
Buttons stop working after populating table view from database, in Javafx
-
22-06-2023 - |
Question
I am populating a Table View from a database, in Javafx. But as soon as the rows show up, the buttons in the same tab with the Table View stop working and throw null pointer exceptions. If I leave the Table View empty, the buttons work fine. The errors occur on the lines with tableColumn...
, if I comment the first one out, the second one breaks and so on. Here's the code:
@Override
public void initialize(URL location, ResourceBundle resources) {
Collection<Reservierung> list;
Collection<Box> list1;
try {
list = service.listReservierung();
tableColumnReservNr.setCellValueFactory(new PropertyValueFactory<Reservierung, Integer>("reservNr"));
tableColumnReservName.setCellValueFactory(new PropertyValueFactory<Reservierung, String>("kundenName"));
tableColumnReservVon.setCellValueFactory(new PropertyValueFactory<Reservierung, Timestamp>("von"));
tableColumnReservBis.setCellValueFactory(new PropertyValueFactory<Reservierung, Timestamp>("bis"));
AlleReservTable.getItems().setAll(list);
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow