Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX application still running after close

Tags:

I'm having problem to close my javaFX application, when I click the close button from my stage, my application disappears but if I look for it in my task manager my application still there without close. I've tried to use this code below to force it close the main thread and all childrens threads but the problem persists.

primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {

            @Override
            public void handle(WindowEvent t) {
                Platform.exit();
            }

        });
like image 279
Victor Laerte Avatar asked Feb 18 '13 14:02

Victor Laerte


People also ask

How do I exit JavaFX application?

The static exit() method in the Platform class is the preferred way to programmatically end a JavaFX program. It is preferred to System. exit() because it cleanly shuts down the application thread and gives it an opportunity to clean up by calling the application's stop() method before terminating.

How do I close all windows JavaFX?

Close a JavaFX application or window by calling the Platform. exit() method to properly close a JavaFX application or window. By performing this method, your entire JavaFX application will close. This means that all of your stages will be closed too.

What is JavaFX platform exit?

exit. public static void exit() Causes the JavaFX application to terminate. If this method is called after the Application start method is called, then the JavaFX launcher will call the Application stop method and terminate the JavaFX application thread. The launcher thread will then shutdown.

Which JavaFX application's lifecycle method the application shuts down?

stop. This method is called when the application should stop, and provides a convenient place to prepare for application exit and destroy resources. The implementation of this method provided by the Application class does nothing. NOTE: This method is called on the JavaFX Application Thread.


1 Answers

Does your application spawn any child threads? If so have you ensured that you terminate them (assuming that they're not daemon threads)?

If your application spawns non-daemon threads then they (and therefore your app) will continue to live on until such time you kill the process

like image 95
Sean Landsman Avatar answered Oct 22 '22 03:10

Sean Landsman