我无法使用 fxml 填充 Javafx TableView

I am not able to populate Javafx TableView using fxml

代码似乎没有问题,但 table 不是 populating.Same 代码在其他地方运行良好。

public class Test implements Initializable {
@FXML
TableView sort_view;
@FXML
TableColumn sort_id, sort_pname, sort_price, sort_quantity, sort_total;
@Override
public void initialize(URL location, ResourceBundle resources) {
    final ObservableList<Sort> data =
            FXCollections.observableArrayList();
    Sort sort;
    SalesDb db = new SalesDb();
    ResultSet rs = db.sortProduct();

    try {
        while (rs.next()) {
            int id = rs.getInt("ID");
            String productName = rs.getString("ProductName");
            String productPrice = rs.getString("ProductPrice");
            String quantity = rs.getString("Quantity");
            String total = rs.getString("Total");

            sort = new Sort(Integer.toString(id),productName,productPrice,quantity,total);
            data.add(sort);
            System.out.println(sort.getId()+","+sort.getProductName()+","+sort.getPrice()+","+sort.getQuantity()+","+sort.getTotal());
        }
    }catch(Exception  e){
        System.out.println("There is an Exception.");
        System.out.println(e.getMessage());
    }
    sort_id.setCellValueFactory(new PropertyValueFactory<Sort, String>("id"));
    sort_pname.setCellValueFactory(new PropertyValueFactory<Sort, String>("productName"));
    sort_price.setCellValueFactory(new PropertyValueFactory<Sort, String>("price"));
    sort_quantity.setCellValueFactory(new PropertyValueFactory<Sort, String>("quantity"));
    sort_total.setCellValueFactory(new PropertyValueFactory<Sort, String>("total"));

    sort_view.getItems().add(data);


}

}

我的fxml文件如下

我的Table没有填充,可能是什么原因。 Table显示如下..

请查看问题所在...

只是没有正确使用命名规则造成的,因为有多个item的 我不得不使用 data.addAll(sort) 而不是 data.add(sort).