如何解决使用 ObservableList 和 TableColums
嗨,有人可以在这段代码中展示如何放置正确的类型。我尝试了很多方法,但是.. 那么如何在 ObservablelIst 和 TableColumn 中放置正确的类型。我是说
**ObservableList data = FXCollections.observableArrayList();**
List<String> newColumnsstring = adminHallintaController.admincombovalidator(tablenameid);
**var col = new TableColumn**(newColumnsstring.get(i));
**col.setCellValueFactory**((Callback<CellDataFeatures<**ObservableList,** String>,ObservableValue<String>>) param -> new SimpleStringProperty(param.getValue().get(j).toString()));
hallintaTable.getColumns().addAll(col);
}
while(rsHaku.next()){
**ObservableList<String> row** = FXCollections.observableArrayList(); --Here
for(int i=1 ; i<=rsHaku.getMetaData().getColumnCount(); i++){
row.add(rsHaku.getString(i));
}
**data.add(row);**
}
private static void addEditButtonToTable(TableView<Object> hallintaTable,String tablenameid) {
**TableColumn col_editaction = new TableColumn<>("Muokkaa");
TableColumn col_delaction = new TableColumn<>("Poista");**
hallintaTable.getColumns().addAll(col_editaction,col_delaction);
**col_editaction.setCellValueFactory**((Callback<CellDataFeatures<Record,Boolean>,ObservableValue<Boolean>>) p -> new SimpleBooleanProperty(p.getValue() != null));
**col_delaction.setCellValueFactory**((Callback<CellDataFeatures<Record,ObservableValue<Boolean>>) p -> new SimpleBooleanProperty(p.getValue() != null));
//Adding the Button to the cell
**col_editaction.setCellFactory**((Callback<TableColumn<Record,TableCell<Record,Boolean>>) p -> new editButtonCell(hallintaTable,tablenameid));
**col_delaction.setCellFactory**((Callback<TableColumn<Record,Boolean>>) p -> new delButtonCell(hallintaTable,tablenameid));
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。