3
I have a theoretical doubt. I was studying Javafx and do not know what the function of Observablelist in this case:
public void start(Stage stage) {
//Creating a Text object
Text text = new Text();
//Setting font to the text
text.setFont(new Font(45));
//setting the position of the text
text.setX(50);
text.setY(150);
//Setting the text to be added.
text.setText("Welcome to Tutorialspoint");
//Creating a Group object
Group root = new Group();
//Retrieving the observable list object
ObservableList list = root.getChildren();
//Setting the text object as a node to the group object
list.add(text);
//Creating a scene object
Scene scene = new Scene(root, 600, 300);
//Setting title to the Stage
stage.setTitle("Sample Application");
//Adding scene to the stage
stage.setScene(scene);
//Displaying the contents of the stage
stage.show();
}
The book I’m studying javafx did so, adding each Node to the Observablelist instead of adding it to the Group itself. I noticed that changes in the Observablelist, since Observablelist receives an Observablelist from the Group, implies changes in the root Group Node. I’d like to know Why use Observablelist...?