JavaFX Applet Web Page Updates and Closes

How to detect when a user closes (moves) or refreshes a web page using a JavaFX applet? I want to do some cleanup in my code on these events.

The Java applet had some callback methods, but how would I do that in JavaFX running in a browser?

+2


source to share


1 answer


Two steps:

  • You may need to use the window.onunload javascript event to tell your JavaFX application to "close". If you do this, you can
  • Add FX.addShutdownAction(myfunction);

    to your function run()

    . This will execute my function when your application is closed.


I don't have the complete code for you here, but I hope this is a start. You may not need to do step 1.

+3


source







All Articles