Good day. The question is this. There is an application written using JavaFX, in which when you click on a button, the Scene object is replaced with a new one via stage.setScene(nextScene) , stage.setScene(nextScene) between windows, as in the installation wizard. Is it possible to somehow tie any animation to this action? That is, for example, the darkening of the original scene, and then when the brightness rises, the next scene is visible.

And is this approach (changing scenes through setScene() ) normal? Maybe there are some other options?

Thank you in advance

  • Strange bug - an alert came to the soap box, saying that there is an answer, I come here - there is no answer. Respond, respond! - Yuri_Prime

1 answer 1

I will answer myself. I changed the concept. The result is this: I created the entire contents of the windows without taking into account Scene objects and the like. I created a controller inheriting from StackPane, which stores the root components (of course, with all its contents) for each window in the HashMap. For our Stage object, we create a single Scene object, in which our controller is the root object. The trick is this. When the contents of the window are changed, the controller deletes all the "children" of the StackPane controller, and adds the root object that I need from the HashMap extracted from it. It is not difficult to attach to this the animation from the discharge Timeline. This solution is partly a reworked solution found here . As a result, the scene does not change, but its contents.