use of com.teamdev.jxbrowser.js.JsObject in project JxBrowser-Examples by TeamDev-IP.
the class JsAccessibleMethod method main.
public static void main(String[] args) {
try (Engine engine = Engine.newInstance(OFF_SCREEN)) {
Browser browser = engine.newBrowser();
browser.mainFrame().ifPresent(frame -> {
JsObject jsObject = frame.executeJavaScript("window");
if (jsObject != null) {
// Inject Java object into JavaScript and associate it
// with the "window.java" JavaScript property.
jsObject.putProperty("java", new JavaObject());
}
// Call the annotated public method of the injected Java object from JS.
frame.executeJavaScript("window.java.sayHello()");
});
}
}
Aggregations