Forum Stats

  • 3,840,393 Users
  • 2,262,599 Discussions


JavaFx Changing Scenes from different Class

3440793 Member Posts: 2
edited Apr 28, 2017 1:29AM in JavaFX 2.0 and Later

Hi, I've seen a descussion of how to change scenes but from the same class. I have to create a game and I divised the displays in classes. The menu class, loading screen class, game class, etc.. I planned to change the scene with the setScene function and then specifying the desired class's scene. Of course i'll have to initiate the desired class first. My question is: Is it the proper way of changing scenes? I'm a beginner and I'm not sure if whether what I'm doing is actually the proper / good way. Cause then, this imples that in each class I'll have to initiate other classes in order to get their scenes and move to them. Any advice plz?  I really need a confirmation on that. Thanks.


  • bouye-JavaNet
    bouye-JavaNet Member Posts: 394 Silver Badge
    edited Apr 27, 2017 4:55PM

    Well... there's nothing special to it... really. You just set a new Scene on the app's Stage and that's it.

    All you need is a reference to that Stage in order to process (for simple applications, you can try to use a singleton pattern in your app).

  • 3440793
    3440793 Member Posts: 2
    edited Apr 28, 2017 1:29AM

    But is it "ok" to create an app like that? The thing is that I'm right now learning how to use JavaFx and I dont know if there is like a proper correct way of doing it. And if this one is "ok", I'll stick with this.

This discussion has been closed.