How can i add children as ArrayList to root and set setCellValueFactory in JavaFx . I want to show second item as text for each node, and use the first one for other computation. the ArrayList has the size of 2 for each node.
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("IT");
Scene scene = new Scene(new Group(), 1200, 1000);
Group sceneRoot = (Group) scene.getRoot();
final TreeItem<String> root = new TreeItem<>("Root Node");
TreeItem<ArrayList<String>> noChild = null;
Set<String> remainingKeysAll = new HashSet<>(dc.getFuncAll().keySet());
remainingKeysAll.removeAll(dc.getCombiFunc().keySet());
for (List<String> values : dc.getCombiFunc().values()) {
remainingKeysAll.removeAll(values);
}
for (String valueRemained : remainingKeysAll) {
ArrayList<String> tempNameId = new ArrayList<>();
tempNameId.add(valueRemained);// function key from all
tempNameId.add(dc.getFuncAll().get(valueRemained).get(1));
//tempNameId has here 9 item in it
noChild = new TreeItem<>(tempNameId);
}
root.getChildren().setAll(noChild);
System.out.println(noChild); // gives TreeItem [ value: [AUF_1087400004054_10476, Patientenabrechnung (stationär)] ] but (There should be 8 other lists.)
Error from root.getChildren -> The method setAll(TreeItem...) in the type ObservableList> is not applicable for the arguments (TreeItem>)
and how should this look like:
firstColumn
.setCellValueFactory((CellDataFeatures<String, String> p) -> new ReadOnlyStringWrapper(
p.getValue().getValue()));