使用 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 (将#修改为@)