Why is my JavaFX TableView empty?

后端 未结 1 602
南笙
南笙 2021-01-26 16:42

I want to populate a TableView and I don\'t know why it\'s empty. I have the following code:

public class StudentTeacherManagementController {
    p         


        
相关标签:
1条回答
  • 2021-01-26 16:43

    First of all, you must set Cell Value Factory for each column of the table in initialize method:

        @Override
        public void initialize(URL url, ResourceBundle rb) {
    
            lastnameCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
            ...
    

    Instead of tableView.getItems.addAll use tableView.setItems.

    0 讨论(0)
提交回复
热议问题