1.声明
//表格 private final TableView<Date> table = new TableView<>(); //数据来源 private final ObservableList<Date> date= FXCollections.observableArrayList();
2. 属性值很重要 一定要和下面创建的表格类数值对应
TableColumn firstCol = new TableColumn("进程id"); firstCol.setMinWidth(100); firstCol.setCellValueFactory( new PropertyValueFactory<>("firstCol")); firstCol.setCellFactory(TextFieldTableCell.forTableColumn());//设置该列表格可编辑 表格类 Data类 public static class Date{ private final SimpleStringProperty firstCol; private final SimpleStringProperty secondaryCol; private final SimpleStringProperty midCol; private final SimpleStringProperty lastCol; public Date(String id, String arrivetime, String midCol, String zztime) { this.firstCol = new SimpleStringProperty(id); this.secondaryCol = new SimpleStringProperty(arrivetime); this.midCol = new SimpleStringProperty(midCol); this.lastCol = new SimpleStringProperty(zztime); } public String getFirstCol() { return firstCol.get(); } public SimpleStringProperty firstColProperty() { return firstCol; } public void setFirstCol(String firstCol) { this.firstCol.set(firstCol); } public String getSecondaryCol() { return secondaryCol.get(); } public SimpleStringProperty secondaryColProperty() { return secondaryCol; } public void setSecondaryCol(String secondaryCol) { this.secondaryCol.set(secondaryCol); } public String getMidCol() { return midCol.get(); } public SimpleStringProperty midColProperty() { return midCol; } public void setMidCol(String midCol) { this.midCol.set(midCol); } public String getLastCol() { return lastCol.get(); } public SimpleStringProperty lastColProperty() { return lastCol; } public void setLastCol(String lastCol) { this.lastCol.set(lastCol); } }
也就是说,下面这个类的参数命名必须是上面的firstCol...