在JavaFX中将TreeItem设置为TreeTableView

时间:2015-03-01 18:18:24

标签: java javafx treetable

我尝试将子设置为root。但不知何故,我的root是空的,虽然treeNodes已加载并且有值。

TreeItem<String> treeNodes = null;
    for (int i = 0; i < rowSize; i++) {

         treeNodes
        = new TreeItem<>(rows.get(i));
        //rows.get(i)
         System.out.println(treeNodes);//is initialized

         root.getChildren().setAll(treeNodes);
         System.out.println(root);//is emty
    }
final TreeTableView<String> treeTableView = new TreeTableView<>(
            root);
TreeTableColumn<String, TreeMap<String, ArrayList<String>>> firstColumn = new TreeTableColumn<>();
    treeTableView.getColumns().add(firstColumn);// Tree column but no item in it, just an arrow facing down.

1 个答案:

答案 0 :(得分:0)

    List<String> functions = new ArrayList<String>(dc.getNameOfFunction());
TreeItem<String> root = new TreeItem<>("Functions");
for (Entry<String, String> entryRow : dc.getSortedfuncAll().entrySet()) {
        root.getChildren().add(new TreeItem<String>(entryRow.getValue()));

    }
final TreeTableView<String> treeTableView = new TreeTableView<>(root);