Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

how to close and open a javafx gui multiple times the correct way..

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I'm working on a javafx simple game project which involves communicating with a server through rmi.
Data for setup will be obtain from the user through a javafx gui which will be closed and opened multiple times depending on how the setup goes.
The javafx gui's are called from the SetUp class which does not extend application itself.
After setup is complete the main game gui(javafx) will be loaded..

Assuming we have two gui's, LoginGui and OptionGui to call in that order..

Problem: call to LoginGui is successful with

Successive calls to OptionGui was not working so I was told to place the line before stage.show () in the first gui class which starts the Application process
and then in my SetUp class after the first gui which is called with "Application.launch(gui.class)" closes, other gui classes can be called with this code example


but the program just jumps this lines of code and continues without showing the OptionGui, can someone pinpoint me the correct way to do this? thanks in advance
 
Sheriff
Posts: 7113
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In general, you don't launch several applications in JavaFX, but you can use several stages.  Stages can be hidden or shown as needed.

So in your case, I would launch the a main GUI but not show the stage.  Then create a second stage that is the login window and show it.  Once the user has successfully logged on, hide the login stage and show the main stage.
 
mike Vigor
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:In general, you don't launch several applications in JavaFX, but you can use several stages.  Stages can be hidden or shown as needed.

So in your case, I would launch the a main GUI but not show the stage.  Then create a second stage that is the login window and show it.  Once the user has successfully logged on, hide the login stage and show the main stage.



ok, can you post a code snippet to launch a stage from outside the gui class? in my example from one of the SetUp class methods? a very short example of launching a first stage and closing it, and launching another one..all in another class's main or method..
 
Knute Snortum
Sheriff
Posts: 7113
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
mike Vigor
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Knute Snortum
Thanks but this is not my problem, I will love to see a snippet on how to call the gui multiple times from another class with a void main, like this for an example using your JavaFxPlay class...
 
Knute Snortum
Sheriff
Posts: 7113
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if that is possible.  The two GUIs need to interact?  If it's a login to a server, maybe test the login first, then launch the second GUI.  Maybe the first GUI talks to the second through a socket.

I think I need to know your use case.  Normally, to log into a server, then use that connection, you would use the model I showed you.  Why do you need to launch a program, login, then go back to launching program to continue?
 
mike Vigor
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:I don't know if that is possible.  The two GUIs need to interact?  If it's a login to a server, maybe test the login first, then launch the second GUI.  Maybe the first GUI talks to the second through a socket.

I think I need to know your use case.  Normally, to log into a server, then use that connection, you would use the model I showed you.  Why do you need to launch a program, login, then go back to launching program to continue?



because the game in itself communicates to a server via rmi, so SetUp is just a controller in the middle, it gets values from the gui, then calles remote objects methods and sends data, when it gets return values or messages from the server, then it fires a gui passing the results from server as parameters, something like that...I hope you get the idea...

I know it can be  done, I just haven't figured how...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic