I am trying populate data ito TableView but somehow it doesn't show anything
This the class where I create the arraylist using it as a type:
public class movieDetails {
private String movieName;
private String description;
private String movieLocation;
private String movieTime;
private int movieThreator;
public movieDetails(String movieName, String description, String movieLocation, String movieTime, int movieThreator) {
this.movieName = movieName;
this.description = description;
this.movieLocation = movieLocation;
this.movieTime = movieTime;
this.movieThreator = movieThreator;
}
movieDetails(String string) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public String getMovieName() {
return movieName;
}
public String getDescription() {
return description;
}
public String getMovieLocation() {
return movieLocation;
}
public String getMovieTime() {
return movieTime;
}
public int getMovieThreator() {
return movieThreator;
}
public void setMovieName(String movieName) {
this.movieName=movieName;
}
public void setDescription(String description ) {
this.description=description;
}
public void setMovieLocation(String movieLocation) {
this.movieLocation=movieLocation;
}
public void setMovieTime(String movieTime) {
this.movieTime=movieTime;
}
public void setMovieThreator(int movieThreator) {
this.movieThreator=movieThreator;
}
}
Then in the database implementation class I return this ObservableList
public ObservableList movies_listView() throws ClassNotFoundException, SQLException{
ObservableList<movieDetails> movieDetails_Table = FXCollections.observableArrayList();
Class.forName(driver);
conn = DriverManager.getConnection(url,dbuser,dbpassw);
ResultSet rs = conn.createStatement().executeQuery("SELECT movie_name,description,cinema_location,time,threator FROM movie");
while(rs.next()){
movieDetails_Table.add(new movieDetails(
rs.getString("movie_name"),
rs.getString("description"),
rs.getString("cinema_location"),
rs.getString("time"),
rs.getInt("threator")
));
}
conn.close();
return movieDetails_Table;
}
And in the main class
TableView<movieDetails> movieDetails_table = new TableView<>();
TableColumn<movieDetails,String> movieNameCal=new TableColumn<>("Movie Name");
TableColumn<movieDetails,String> movieDesCal=new TableColumn<>("Description");
TableColumn<movieDetails,String> movieLocCal=new TableColumn<>("Movie Location");
TableColumn<movieDetails,String> movieTimCal=new TableColumn<>("Movie Time");
TableColumn<movieDetails,Integer> movieThreCal=new TableColumn<>("Movie Threator");
movieNameCal.setCellValueFactory(new PropertyValueFactory<>("movie Name"));
movieDesCal.setCellValueFactory(new PropertyValueFactory<>("description"));
movieLocCal.setCellValueFactory(new PropertyValueFactory<>("movie Location"));
movieTimCal.setCellValueFactory(new PropertyValueFactory<>("movie Time"));
movieThreCal.setCellValueFactory(new PropertyValueFactory<>("movie Threator"));
movieDetails_table.getColumns().add(movieNameCal);
movieDetails_table.getColumns().add(movieDesCal);
movieDetails_table.getColumns().add(movieLocCal);
movieDetails_table.getColumns().add(movieTimCal);
movieDetails_table.getColumns().add(movieThreCal);
deleteMovie_pane.setCenter(movieDetails_table);
// this button to navigate the scene where the table in
deleteMovie_button.setOnAction(e->{
try {
movieDetails_table.setItems(db.movies_listView());
primaryStage.setTitle("Delete Movie Scene");
primaryStage.setScene(deleteMovie_scene);
primaryStage.show();
} catch (ClassNotFoundException | SQLException ex) {
Logger.getLogger(Java_CinemaTicket.class.getName()).log(Level.SEVERE, null, ex);
}
});
Once I run the IDE indicate no errors but it show only one column fill with information but the rest nothin
The output picture
and this the database picture: