I need to draw an ImageView (Play button) before each track loaded from the database, but for some reason it doesn't load. No errors occur, but the button is simply not added to the line with the loaded track. I've already tried all possible methods. Maybe someone can tell me what's wrong
@Override
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
try {
column_track.setCellValueFactory(new PropertyValueFactory<>("title"));
column_artist.setCellValueFactory(new PropertyValueFactory<>("artist"));
column_genre.setCellValueFactory(new PropertyValueFactory<>("genre"));
column_duration.setCellValueFactory(new PropertyValueFactory<>("duration"));
column_play.setCellFactory(new Callback<TableColumn<Track, ImageView>, TableCell<Track, ImageView>>() {
@Override
public TableCell<Track, ImageView> call(TableColumn<Track, ImageView> param) {
return new TableCell<Track, ImageView>() {
private final ImageView imageView = new ImageView();
@Override
protected void updateItem(ImageView item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setGraphic(null);
} else {
imageView.setImage(new Image("images/icon-play-gray.png"));
imageView.setFitWidth(50);
imageView.setFitHeight(50);
setGraphic(imageView);
}
}
};
}
});
table_tracks.setItems(trackList);
loadTracks();
} catch (Exception e) {
e.printStackTrace();
}
}
}
PropertyValueFactory-> that is not the root cause of your error though.