Search code examples
webviewjavafx-2disposedestroy

Destroy/Dispose WebView


Is there a way to destroy a WebView instance? If a page loads, and say a video starts playing, I want to be able, when I hide the WebView, basically to destroy it, or at least to reset it. I know I could listen to the visibleProperty and do a getEngine().load() But I was wondering if there was something better. Also, the visibleProperty only changes if the actual webView.setVisible(false) is executed right? It does not track, for example, that the parent node of the webview has been made not visible. Appreciate your help.


Solution

  • In case this helps somebody,

    webView.getEngine().load(null);

    seems to be doing the trick, and it's what I'm using right now.