Platform.runLater(() -> {
WebView wv = new WebView();
final WebEngine engine = wv.getEngine();
fxpanel.setScene(new Scene(wv));
engine.setJavaScriptEnabled(true);
engine.load(Url);
};
and when I close this frame when this WebView
is open I can see them is running in the background, so I try to close it like this in one public void class but it is not close properly so how can I do it.
当我在打开这个WebView时关闭这个框架,我可以看到它们在后台运行,所以我尝试在一个公共的void类中关闭它,但它没有正确关闭,所以我怎么能这样做。
public static void closeframe() {
Platform.setImplicitExit(false);
if (ClassName != null) {
ClassName.frame.dispose();
Platform.runLater(() -> {
wv = new WebView();
ClassName.wv.getEngine().reload();
ClassName.wv = null;
ClassName.frame = null;
});
1 个解决方案
#1
1
exit PlatForm in stop Method Like this:
在stop中退出PlatForm方法如下:
public class Main extends Application {
//Entry point to application
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Parent authScene = (Parent) FXMLLoader.load(getClass().getResource("/View/Auth.fxml"));
Scene scene = new Scene(authScene);
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.setTitle("Green Project : Login Form");
primaryStage.show();
}
@Override
public void stop() {
Platform.exit();
}
}
#1
1
exit PlatForm in stop Method Like this:
在stop中退出PlatForm方法如下:
public class Main extends Application {
//Entry point to application
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Parent authScene = (Parent) FXMLLoader.load(getClass().getResource("/View/Auth.fxml"));
Scene scene = new Scene(authScene);
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.setTitle("Green Project : Login Form");
primaryStage.show();
}
@Override
public void stop() {
Platform.exit();
}
}