2

I am writing a game in which I am using jMonkeyEngine and JavaFx. I have a launcher written in JavaFx that can launch a new thread and run jMonkeyEngine on that thread. When it does so, it calls Platform.exit() such that the game's process ends when the jMonkeyEngine threads end.

This works exactly as it should, except when the game crashes. In this scenario, I would like to restart JavaFx to provide a crash dialog to the user. My first thought was to create a separate CrashDialoge class that extends Application, but this isn't practical because the static launch method creates a new instance of the CrashDialoge class, thus making passing of a Throwable object containing the crash information impossible. I know I can use a static variable to circumvent this, but this would break if for some reason more than one CrashDialoge is being created. I can get around this with Locks, but I am wondering if there is a better way to pass the Throwable object to the new application, perhaps by launching JavaFx with an existing Application object.

john01dav
  • 1,842
  • 1
  • 21
  • 40
  • show your application class, and you might get a straight forward solutinon – Elltz Apr 14 '17 at 20:10
  • @Elltz I have not even written the application class since the first thing I would do when writing it is figure out a way to pass in the Throwable. Also, I have two application classes: one for the crash part, and another for the login screen that is launched before jMonkeyEngine. – john01dav Apr 14 '17 at 22:56

0 Answers0