I have a client application, and I want to get the server address, port, and some other info from the user in order to initialize the controller of the main stage. Currently my code look like this
public class MemoryGameClient extends Application {
@Override
public void start(Stage mainStage) throws Exception {
FXMLLoader fxml = new FXMLLoader(getClass().getResource("MemoryGameClient.fxml"));
MemoryGameClientController controller = fxml.getController()
Parent root = loader.load();
controller.connect(SERVER_ADDRESS, PORT, GAME_BOARD_SIZE);
Scene scene = new Scene(root);
mainStage.setScene(scene);
mainStage.show()
}
public static void main(String[] args) {
launch(args);
}
}
It works fine using the hardcoded values, but I want to be able to open a DialogPane or something like that to get those values from user before initializing the scene
and running the main application logic.
Can I set an empty Scene
that launch a dialog and after that quitting and starting the main stage? Can I do that from the controller before mainStage.show()
?
(I need the user input not only for connecting the server but also to determine the size of the GridPane
in root
)