-1

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

enter image description here

and this the database picture:

enter image description here

MrRizk
  • 111
  • 5
  • 14
  • Where are you adding the columns to the table? – James_D Dec 05 '16 at 14:18
  • not sure really how to add them – MrRizk Dec 05 '16 at 14:19
  • 1
    Is it really easier to post a question here than to read some [documentation](http://docs.oracle.com/javase/8/javafx/user-interface-tutorial/table-view.htm#CJAGAAEE)? Even the [`TableView` Javadocs](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TableView.html) include how to do this. – James_D Dec 05 '16 at 14:22
  • sometime it's just better to get the experience from the experts – MrRizk Dec 05 '16 at 14:24
  • @James_D I got issue not all the information in the database being populate to the tableview do you know why. I uploaded the question may you see it – MrRizk Dec 05 '16 at 14:34
  • Did you try searching for a solution to that? – James_D Dec 05 '16 at 14:35
  • @James_D I did but haven't found anything – MrRizk Dec 05 '16 at 14:37
  • 1
    http://stackoverflow.com/search?q=%5Bjavafx%5D+tableview+not+all+columns+showing+data The very first hit on that search is http://stackoverflow.com/questions/18971109/javafx-tableview-not-showing-data-in-all-columns – James_D Dec 05 '16 at 14:37
  • @James_D thanks man the link is really helpful – MrRizk Dec 05 '16 at 14:46

1 Answers1

2

You haven't added the columns to the table. Use

movieDetails_table.getColumns().add(movieNameCal);

etc.

James_D
  • 201,275
  • 16
  • 291
  • 322