缺少来自wekaapi的JavaFX tableView内容
我在javaFX表视图中可视化arff文件时遇到了一个大问题。我的代码:缺少来自wekaapi的JavaFX tableView内容,java,javafx,weka,Java,Javafx,Weka,我在javaFX表视图中可视化arff文件时遇到了一个大问题。我的代码: ArffLoader loader = new ArffLoader(); loader.setFile(arff); Instances data = loader.getDataSet(); List<TableColumn<Instance, String>> atrributes = new ArrayList<>(); for (int
ArffLoader loader = new ArffLoader();
loader.setFile(arff);
Instances data = loader.getDataSet();
List<TableColumn<Instance, String>> atrributes = new ArrayList<>();
for (int i = 0; i < data.numAttributes(); i++) {
atrributes.add(new TableColumn<Instance,String>` (data.attribute(i).name()));
}
List <Instance> instances = new ArrayList<>();
for (int i =0;i<data.size();i++)
{
instances.add(data.get(i));
}
ObservableList<Instance> tableContent = FXCollections.observableArrayList(instances);
table.getColumns().removeAll();
table.getColumns().addAll(atrributes);
table.setItems(tableContent);
table.setVisible(true);
ArffLoader loader=新的ArffLoader();
setFile(arff);
实例数据=loader.getDataSet();
List atributes=new ArrayList();
对于(int i=0;i 对于(int i=0;i您需要为每个表列设置单元格值工厂。这是一个将每行中的实例
映射到该列中相应单元格中显示的值的函数
我不熟悉Weka,但是看看这个,我觉得你需要
for (int i = 0; i < data.numAttributes(); i++) {
TableColumn<Instance, String> column
= new TableColumn<Instance,String>(data.attribute(i).name());
final int attIndex = i ;
column.setCellValueFactory(cellData ->
new SimpleStringProperty(cellData.getValue().toString(attIndex)));
atrributes.add(column);
}
for(int i=0;i
新的SimpleStringProperty(cellData.getValue().toString(attIndex));
添加(列);
}