public final class FXBrowsers extends Object
WebView and JavaScriptBody code
in existing JavaFX applications.
This class is for those who want to instantiate their own WebView,
configure it manually, embed it into own JavaFX
application and based on other events in the application
re-execute code
inside of such WebViews.
In case such detailed control is not necessary,
consider using BrowserBuilder.| Modifier and Type | Method and Description |
|---|---|
static void |
load(WebView webView,
URL url,
Class<?> onPageLoad,
String methodName,
String... args)
Enables the Java/JavaScript bridge (that supports
JavaScriptBody and co.)
in the provided webView. |
static void |
load(WebView webView,
URL url,
Runnable onPageLoad)
Enables the Java/JavaScript bridge (that supports
JavaScriptBody and co.)
in the provided webView. |
static void |
runInBrowser(WebView webView,
Runnable code)
Executes a code inside of provided
WebView. |
public static void load(WebView webView, URL url, Class<?> onPageLoad, String methodName, String... args)
JavaScriptBody and co.)
in the provided webView. This method returns
immediately. Once the support is active, it calls back specified
method in onPageLoad class - the class can possibly be
loaded by a different classloader (to enable replacement of
methods with JavaScriptBody annotations with executable
versions). The method methodName needs to be public
(in a public class), static and take either no parameters
or an array of Strings.
This method sets Node.getUserData() and runInBrowser(javafx.scene.web.WebView, java.lang.Runnable)
relies on the value. Please don't alter it.
webView - the instance of Web View to tweakurl - the URL of the HTML page to load into the viewonPageLoad - callback class with method methodNamemethodName - the method to call when the page is loadedargs - arguments to pass to the methodName methodpublic static void load(WebView webView, URL url, Runnable onPageLoad)
JavaScriptBody and co.)
in the provided webView. This method returns
immediately. Once the support is active, it calls back specified
method in onPageLoad's run method.
This is more convenient way to initialize the webview,
but it requires one to make sure
all JavaScriptBody methods has been post-processed during
compilation and there will be no need to instantiate new classloader.
This method sets Node.getUserData() and runInBrowser(javafx.scene.web.WebView, java.lang.Runnable)
relies on the value. Please don't alter it.
webView - the instance of Web View to tweakurl - the URL of the HTML page to load into the viewonPageLoad - callback to call when the page is readypublic static void runInBrowser(WebView webView, Runnable code)
WebView. This method
is associates the execution context with provided browser,
so the JavaScriptBody annotations know where to execute
their JavaScript bodies.
The code is going to be executed synchronously
in case Platform.isFxApplicationThread() returns true.
Otherwise this method returns immediately and the code is executed
later via Platform.runLater(java.lang.Runnable).
This method relies on Node.getUserData() being properly
provided by the load methods in this class.
webView - the web view previously prepared by one of the load
in this classcode - the code to executeIllegalArgumentException - if the web view was not properly
initializedBrwsrCtx.execute(java.lang.Runnable)Copyright © 2014 NetBeans. All Rights Reserved.