Java Code Examples for netscape.javascript.JSObject#setMember()
The following examples show how to use
netscape.javascript.JSObject#setMember() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Demo_VirtualCursor.java From haxademic with MIT License | 6 votes |
protected void initWebView() { // build WebView & JavaFX components on JavaFX thread // init WebView component // load page & attach js bridge to call up to java webView = new WebView(); // webView.setDisable(true); // disable keyboard/mouse webEngine = webView.getEngine(); webEngine.load("http://192.168.1.3:3333/touchless/sdk/javascript/#mode=kiosk&customerId=hovercraft&deviceId=1234567890&debug=true"); P.println("webEngine.getUserAgent()", webEngine.getUserAgent()); // init js bridge with this class as the deletage JSObject win = (JSObject) webEngine.executeScript("window"); win.setMember("native", this); // add WebView to FXPanel/JFrame Scene scene = new Scene(webView, jframe.getWidth(), jframe.getHeight(), Color.web("#666970")); fxPanel.setScene(scene); jframe.setContentPane(fxPanel); // set special window properties // fxPanel.setFocusable(false); // fxPanel.setFocusTraversalKeysEnabled(true); // fxPanel.requestFocus(); // fxPanel.requestFocusInWindow(); }
Example 2
Source File: VirtualCursor.java From haxademic with MIT License | 6 votes |
public Browser(int w, int h) { this.w = w; this.h = h; thiss = this; webView = new WebView(); webEngine = webView.getEngine(); getChildren().add(webView); //apply the styles // getStyleClass().add("browser"); // load the web page // load page & attach js bridge to call up to java P.println(webEngine.getUserAgent()); webEngine.load("http://192.168.1.3:3333/touchless/sdk/javascript/#mode=kiosk&customerId=hovercraft&deviceId=1234567890"); P.out("Adding js callback!"); JSObject win = (JSObject) webEngine.executeScript("window"); win.setMember("native", thiss); }
Example 3
Source File: DevToolsDebuggerJsBridge.java From Javafx-WebView-Debugger with MIT License | 6 votes |
/** * Inject JSBridge and initialize the JavaScript helper * <p> * Call when engine transitions state to READY after a page load is started in WebView or requested * by Chrome dev tools. * <p> * This means after either the {@link #pageReloading()} is called or {@link #pageReloadStarted()} * is invoked to inform of page reloading operation. */ public void connectJsBridge() { JSObject jsObject = (JSObject) myWebView.getEngine().executeScript("window"); jsObject.setMember("__MarkdownNavigatorArgs", myJfxScriptArgAccessor); // this interface stays for the duration, does not give much jsObject.setMember("__MarkdownNavigator", getJfxDebugProxyJsBridge()); // this interface is captured by the helper script since incorrect use can bring down the whole app try { if (mySuppressNoMarkdownException) { myWebView.getEngine().executeScript("var markdownNavigator; markdownNavigator && markdownNavigator.setJsBridge(window.__MarkdownNavigator);"); } else { myWebView.getEngine().executeScript("markdownNavigator.setJsBridge(window.__MarkdownNavigator);"); } } catch (JSException e) { e.printStackTrace(); LOG.warn("jsBridgeHelperScript: exception", e); } jsObject.removeMember("__MarkdownNavigator"); }
Example 4
Source File: MaxZoomService.java From GMapsFX with Apache License 2.0 | 6 votes |
public void getMaxZoomAtLatLng(LatLong loc, MaxZoomServiceCallback callback) { this.callback = callback; JSObject doc = (JSObject) getJSObject().eval("document"); doc.setMember(getVariableName(), this); StringBuilder r = new StringBuilder(getVariableName()) .append(".") .append("getMaxZoomAtLatLng(") .append(loc.getVariableName()) .append(", ") .append("function(result) {document.") .append(getVariableName()) .append(".processResponse(result);});"); // System.out.println("MaxZoomService direct call: " + r.toString()); getJSObject().eval(r.toString()); }
Example 5
Source File: GeocodingService.java From GMapsFX with Apache License 2.0 | 6 votes |
public void getGeocoding(GeocoderRequest req, GeocodingServiceCallback callback){ this.callback = callback; JSObject doc = (JSObject) getJSObject().eval("document"); doc.setMember(getVariableName(), this); StringBuilder r = new StringBuilder(getVariableName()) .append(".") .append("geocode(") .append(req.getVariableName()) .append(", ") .append("function(results, status) {alert('rec:'+status);\ndocument.") .append(getVariableName()) .append(".processResponse(results, status);});"); LOG.trace("Geocoding direct call: " + r.toString()); getJSObject().eval(r.toString()); }
Example 6
Source File: DirectionsService.java From GMapsFX with Apache License 2.0 | 6 votes |
public void getRoute(DirectionsRequest req, DirectionsServiceCallback callback, DirectionsRenderer renderer){ this.callback = callback; this.renderer = renderer; JSObject doc = (JSObject) getJSObject().eval("document"); doc.setMember(getVariableName(), this); StringBuilder r = new StringBuilder(getVariableName()) .append(".") .append("route(") .append(req.getVariableName()) .append(", ") .append("function(results, status) {\n") .append("if(status === 'OK'){\n") .append(renderer.getVariableName()) .append(".setDirections(results);\ndocument.") .append(getVariableName()) .append(".processResponse(results, status);\n}") .append("});"); LOG.trace("Directions direct call: " + r.toString()); try{ getJSObject().eval(r.toString()); } catch(Throwable t){ LOG.error(t.getMessage()); } }
Example 7
Source File: ElevationService.java From GMapsFX with Apache License 2.0 | 6 votes |
/** Create a request for elevations for samples along a path. * * @param req * @param callback */ public void getElevationAlongPath(PathElevationRequest req, ElevationServiceCallback callback) { this.callback = callback; JSObject doc = (JSObject) getJSObject().eval("document"); doc.setMember(getVariableName(), this); StringBuilder r = new StringBuilder(getVariableName()) .append(".") .append("getElevationAlongPath(") .append(req.getVariableName()) .append(", ") .append("function(results, status) {document.") .append(getVariableName()) .append(".processResponse(results, status);});"); getJSObject().eval(r.toString()); }
Example 8
Source File: ElevationService.java From GMapsFX with Apache License 2.0 | 6 votes |
/** Create a request for elevations for multiple locations. * * @param req * @param callback */ public void getElevationForLocations(LocationElevationRequest req, ElevationServiceCallback callback) { this.callback = callback; JSObject doc = (JSObject) getJSObject().eval("document"); doc.setMember(getVariableName(), this); StringBuilder r = new StringBuilder(getVariableName()) .append(".") .append("getElevationForLocations(") .append(req.getVariableName()) .append(", ") .append("function(results, status) {alert('rec:'+status);\ndocument.") .append(getVariableName()) .append(".processResponse(results, status);});"); LOG.trace("ElevationService direct call: " + r.toString()); getJSObject().eval(r.toString()); }
Example 9
Source File: DirectionsPane.java From GMapsFX with Apache License 2.0 | 5 votes |
/** * Registers an event handler in the repository shared between Javascript * and Java. * * @param h Event handler to be registered. * @return Callback key that Javascript will use to find this handler. */ private String registerEventHandler(GFXEventHandler h) { //checkInitialized(); if (!registeredOnJS) { JSObject doc = (JSObject) runtime.execute("document"); doc.setMember("jsHandlers", jsHandlers); registeredOnJS = true; } return jsHandlers.registerHandler(h); }
Example 10
Source File: GoogleMapView.java From GMapsFX with Apache License 2.0 | 5 votes |
private void initialiseScript() { if (!usingCustomHtml) { JSObject window = (JSObject) webengine.executeScript("window"); window.setMember("libLoadBridge", new MapLibraryLoadBridge()); String script = "loadMapLibrary('" + GOOGLE_MAPS_API_VERSION + "','" + key + "','" + language + "','" + region + "');"; webengine.executeScript(script); } else { setInitialized(true); fireMapInitializedListeners(); } }
Example 11
Source File: GoogleMap.java From GMapsFX with Apache License 2.0 | 5 votes |
/** * Registers an event handler in the repository shared between Javascript * and Java. * * @param h Event handler to be registered. * @return Callback key that Javascript will use to find this handler. */ private String registerEventHandler(GFXEventHandler h) { //checkInitialized(); if (!registeredOnJS) { JSObject doc = (JSObject) runtime.execute("document"); doc.setMember("jsHandlers", jsHandlers); registeredOnJS = true; } return jsHandlers.registerHandler(h); }
Example 12
Source File: WebviewSnapshotter.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
private void fireJSSnap(int x, int y, int w, int h) { if (!Platform.isFxApplicationThread()) { Platform.runLater(()-> { fireJSSnap(x, y, w, h); }); return; } //System.out.println("in FireJSSnap "+x+","+y+","+w+","+h); JSObject window = (JSObject)web.getEngine().executeScript("window"); window.setMember("snapper", this); web.getEngine().executeScript("getRectSnapshot("+x+","+y+","+w+","+h+");"); }
Example 13
Source File: RFXWebView.java From marathonv5 with Apache License 2.0 | 5 votes |
private void loadScript(WebView webview) { webview.getProperties().put("current_selector", "body"); WebEngine webEngine = webview.getEngine(); JSObject win = (JSObject) webEngine.executeScript("window"); win.setMember("marathon_recorder", RFXWebView.this); webEngine.executeScript(script); }
Example 14
Source File: ChatShowPane.java From oim-fx with MIT License | 5 votes |
private void initWeb(WebEngine webEngine) { JSObject window = (JSObject) webEngine.executeScript("window"); // JSObject window = (JSObject) webEngine.executeScript("document"); if (isLoad && null != member) { window.setMember("oim", member); } }
Example 15
Source File: ShowPanel.java From oim-fx with MIT License | 5 votes |
private void initWeb(WebEngine webEngine) { JSObject window = (JSObject) webEngine.executeScript("window"); // JSObject window = (JSObject) webEngine.executeScript("document"); if(isLoad&&null!=member){ window.setMember("oim", member); } }
Example 16
Source File: WritePanel.java From oim-fx with MIT License | 4 votes |
private void initWeb(WebEngine webEngine) { JSObject window = (JSObject) webEngine.executeScript("window"); window.setMember("oim", new JavaApplication()); }
Example 17
Source File: BrowserJavascript.java From mars-sim with GNU General Public License v3.0 | 4 votes |
private void addFunctionHandlerToDocument(WebEngine engine) { JSObject window = (JSObject) engine.executeScript("window"); window.setMember("app", this); }
Example 18
Source File: WebApplicationRegion.java From greenbeans with Apache License 2.0 | 4 votes |
private void installConsoleBridge() { JSObject windowObject = getJsWindow(); windowObject.setMember(JS_MEMBER_NAME_CONSOLE_BRIDGE, consoleBridge); webEngine.executeScript("console.log = function(message) {\nconsoleBridge.log(message);\n};"); }
Example 19
Source File: WebApplicationRegion.java From greenbeans with Apache License 2.0 | 4 votes |
private void installServiceLocator(ServiceLocator serviceLocator) { JSObject windowObject = getJsWindow(); windowObject.setMember(JS_MEMBER_NAME_APP_SERVICE_LOCATOR, serviceLocator); }
Example 20
Source File: ChatWritePane.java From oim-fx with MIT License | 4 votes |
private void initWeb(WebEngine webEngine) { JSObject window = (JSObject) webEngine.executeScript("window"); window.setMember("oim", new JavaApplication()); }