What I'm trying to implement is essentially the cancel button of a browser but using JavaFX's webview. This is the code I have so far:
Worker<Void> loadWorker = webView.getEngine().getLoadWorker();
if (loadWorker != null) {
Platform.runLater(() -> loadWorker.cancel());
}
but it sometimes work and sometimes doesn't.
What's the proper way of canceling the webview/webengine task of loading a page?