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. Btw. when using the BrowserBuilder
one can execute presenter in headless mode. Just specify:
System.setProperty("fxpresenter.headless", "true");
| Modifier and Type | Method and Description |
|---|---|
static void |
load(javafx.scene.web.WebView webView,
URL url,
Class<?> onPageLoad,
String methodName,
String... args)
Enables the Java/JavaScript bridge (that supports
JavaScriptBody and co.) |
static void |
load(javafx.scene.web.WebView webView,
URL url,
Runnable onPageLoad)
Enables the Java/JavaScript bridge (that supports
JavaScriptBody and co.) |
static void |
load(javafx.scene.web.WebView webView,
URL url,
Runnable onPageLoad,
ClassLoader loader)
Enables the Java/JavaScript bridge (that supports
JavaScriptBody and co.) |
static void |
load(javafx.scene.web.WebView webView,
URL url,
Runnable onPageLoad,
ClassLoader loader,
Object... context)
Enables the Java/JavaScript bridge (that supports
JavaScriptBody and co.) |
static void |
runInBrowser(javafx.scene.web.WebView webView,
Runnable code)
Executes a code inside of provided
WebView. |
public static void load(javafx.scene.web.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 FXBrowsers.runInBrowser(javafx.scene.web.WebView, java.lang.Runnable)
relies on the value. Please don't alter it.
Since introduction of technology identifiers the
provided args strings are also passed to the
context when it is being
created
and can influence the selection
of available technologies
(like Technology,
Transfer or
WSTransfer).
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(javafx.scene.web.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 FXBrowsers.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 load(javafx.scene.web.WebView webView,
URL url,
Runnable onPageLoad,
ClassLoader loader)
JavaScriptBody and co.)
in the provided webView. This method returns
immediately. Once the support is active, it calls back run
method in onPageLoad.
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 FXBrowsers.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 readyloader - the loader to use when constructing initial BrwsrCtx or nullpublic static void load(javafx.scene.web.WebView webView,
URL url,
Runnable onPageLoad,
ClassLoader loader,
Object... context)
JavaScriptBody and co.)
in the provided webView. This method returns
immediately. Once the support is active, it calls back run
method in onPageLoad.
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 FXBrowsers.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 readyloader - the loader to use when constructing initial BrwsrCtx or nullcontext - additonal configuration to pass to BrowserBuilder.newBrowser(java.lang.Object...)
and Contexts.newBuilder(java.lang.Object...) factory methodspublic static void runInBrowser(javafx.scene.web.WebView webView,
Runnable code)
WebView. This method
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
methods in this classcode - the code to executeIllegalArgumentException - if the web view was not properly
initializedBrwsrCtx.execute(java.lang.Runnable)Copyright © 2019 The Apache Software Foundation. All rights reserved.