I'm asking regarding the relationships between Nodes, Scenes and Parents. I'm actually studying JavaFX and is difficult change scenes in the same frame. I founded a way for do that, but actually I don't know how it works. Can you help me figure it out ?
I tried looking for on the Java reference, on youtube and also writing on google the keyword "Scenes Parent" but I didn't found anything that helped me.
public class SceneCreator {
// launching the new scene based on the .fxml file name passed in the argument as a String variable
// building the scene and setting the value for the instance variable loader
public static void launchScene (String sceneName) throws IOException {
// Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
FXMLLoader loader = new FXMLLoader(Main.class.getResource(sceneName));
Main.setRoot(loader.load());
Scene scene = new Scene(Main.getRoot());
Main.getStage().setScene(scene);
Main.getStage().show();
@FXML
private void sphereClick() throws IOException{
System.out.println("Sphere button clicked");
SceneCreator.launchScene("sphere.fxml");
}