Code:
@Override
public void start(Stage stage) throws Exception {
final TreeItem tn = new TreeItem("root");
TreeItem tn1 = new TreeItem("node1");
TreeView treeView = new TreeView(tn);
tn.getChildren().add(tn1);
final Button button = new Button("Apply graphic");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
tn.setGraphic(new Rectangle(0, 0, 10, 10));
}
});
VBox pane = new VBox();
pane.getChildren().addAll(treeView, button);
Scene scene = new Scene(pane, 300, 700);
stage.setScene(scene);
stage.show();
}
Look at the attached movie.
I set new graphic (on movie, using binding, in the attached code, using setter). You can see, that change listener in movie notified, that rectangle became a value of graphic property of node (ROOT). But it will be applied, on when node will be expanded/collapsed.
To reproduce - click the button in the attached code, and expand or collapse a node.
@Override
public void start(Stage stage) throws Exception {
final TreeItem tn = new TreeItem("root");
TreeItem tn1 = new TreeItem("node1");
TreeView treeView = new TreeView(tn);
tn.getChildren().add(tn1);
final Button button = new Button("Apply graphic");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
tn.setGraphic(new Rectangle(0, 0, 10, 10));
}
});
VBox pane = new VBox();
pane.getChildren().addAll(treeView, button);
Scene scene = new Scene(pane, 300, 700);
stage.setScene(scene);
stage.show();
}
Look at the attached movie.
I set new graphic (on movie, using binding, in the attached code, using setter). You can see, that change listener in movie notified, that rectangle became a value of graphic property of node (ROOT). But it will be applied, on when node will be expanded/collapsed.
To reproduce - click the button in the attached code, and expand or collapse a node.