Issue
One approach is that we change scenes in Stage
using setScene()
method.
Different one, is to set root of Scene
using setRoot()
method.
Which one to use and when? Are there any advantages/disadvantages and consenquences of using each one of those?
Solution
- Stage.setScene() changes the entire JFX appearance (like a theater when the stage is replaced by a new scene)
- Scene.setRoot() allows to switch the current scene to a new scene which is one of the scenes in a group.
Also If you switch the scene, you’ll lose properties associated with the scene. typically, for example, you load the style sheet into the scene, so if you change the scene you’d lose CSS styling, or need to load the style sheet again. Similarly, you’d lost the background color, size, etc. so it really just depends on whether you want to keep those properties or replace them.
Answered By - user2670200