Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关闭java应用程序中的Javafx类应用程序_Java_Webview_Javafx - Fatal编程技术网

关闭java应用程序中的Javafx类应用程序

关闭java应用程序中的Javafx类应用程序,java,webview,javafx,Java,Webview,Javafx,我有一个java应用程序,这有一个带有javafx应用程序的弹出窗口,其中嵌入了来自Youtube的视频。我正确地看到了这一点,但是当我关闭这个弹出窗口时,javafx线程不会关闭,并且javafx应用程序在后台运行。这是我的javafx类: public class JavaFXClass extends Application { @Override public void start(final Stage stage) throws Exception { final WebVi

我有一个java应用程序,这有一个带有javafx应用程序的弹出窗口,其中嵌入了来自Youtube的视频。我正确地看到了这一点,但是当我关闭这个弹出窗口时,javafx线程不会关闭,并且javafx应用程序在后台运行。这是我的javafx类:

public class JavaFXClass extends Application {
@Override
public void start(final Stage stage) throws Exception {
    final WebView webview = new WebView();
    /*...*/
    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
        @Override
        public void handle(WindowEvent event) {
            Platform.runLater( new Runnable() {
                @Override
                public void run() {
                    //I need stop javafx when this class close.
                }
            });
        }  
    });
    stage.show();
}

public static void LoadClass(String Data) { //I use this function to load class
    /*...*/
    launch(); //return error when i re-call this function (already launch).
}
如果我将webview.getEngine.loadnull;站台出口;OnCloseRequest中的代码工作正常,但在toolkit未运行时尝试调用defer会创建异常

我需要使用webview.getEngine.loadnull;或者类似,因为如果我不使用它,webview中的视频仍在后台播放。如果我不使用Platform.exit,退出主框架崩溃锁

对不起,我的英语不好,我试着尽我所能写得最好。用这个:

[...]
stage.setOnCloseRequest(this.getCloseSystemEvent());
}

public EventHandler<WindowEvent> getCloseSystemEvent() {
    return new EventHandler<WindowEvent>() {
        @Override
        public void handle(WindowEvent event) {
            Platform.exit();
        }
    };
}
此外,还应该检查并发API。代码会阻止运行时正确关闭线程