當前位置: 首頁>>代碼示例>>Java>>正文


Java JSObject.setMember方法代碼示例

本文整理匯總了Java中netscape.javascript.JSObject.setMember方法的典型用法代碼示例。如果您正苦於以下問題:Java JSObject.setMember方法的具體用法?Java JSObject.setMember怎麽用?Java JSObject.setMember使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在netscape.javascript.JSObject的用法示例。


在下文中一共展示了JSObject.setMember方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadResults

import netscape.javascript.JSObject; //導入方法依賴的package包/類
public void loadResults() {
    try {
        JSObject windowObj = (JSObject)webEngine.executeScript("window");
        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(testResult);
        windowObj.setMember("result", json);
        try {
            webEngine.executeScript("refreshResult()");
        } catch (JSException js) {
            Logger.error(js, "error updating result");
        }

    } catch (JsonProcessingException e) {
        return;
    }
}
 
開發者ID:loadtestgo,項目名稱:pizzascript,代碼行數:17,代碼來源:ViewResultsPanel.java

示例2: sendJsTextStatus

import netscape.javascript.JSObject; //導入方法依賴的package包/類
void sendJsTextStatus(String message) {
  if (!haveDocumentAccess || statusForm == null || statusText == null)
    return;
  try {
    JSObject jsoWindow = JSObject.getWindow(appletWrapper);
    JSObject jsoDocument = (JSObject) jsoWindow.getMember("document");
    JSObject jsoForm = (JSObject) jsoDocument.getMember(statusForm);
    if (statusText != null) {
      JSObject jsoText = (JSObject) jsoForm.getMember(statusText);
      jsoText.setMember("value", message);
    }
  } catch (Exception e) {
    Logger.error("error indicating status at document." + statusForm + "."
        + statusText + ":" + e.toString());
  }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:17,代碼來源:Jmol.java

示例3: sendJsTextareaStatus

import netscape.javascript.JSObject; //導入方法依賴的package包/類
void sendJsTextareaStatus(String message) {
  if (!haveDocumentAccess || statusForm == null || statusTextarea == null)
    return;
  try {
    JSObject jsoWindow = JSObject.getWindow(appletWrapper);
    JSObject jsoDocument = (JSObject) jsoWindow.getMember("document");
    JSObject jsoForm = (JSObject) jsoDocument.getMember(statusForm);
    if (statusTextarea != null) {
      JSObject jsoTextarea = (JSObject) jsoForm.getMember(statusTextarea);
      if (message == null) {
        jsoTextarea.setMember("value", "");
      } else {
        String info = (String) jsoTextarea.getMember("value");
        jsoTextarea.setMember("value", info + "\n" + message);
      }
    }
  } catch (Exception e) {
    Logger.error("error indicating status at document." + statusForm + "."
        + statusTextarea + ":" + e.toString());
  }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:22,代碼來源:Jmol.java

示例4: executeWithResultString

import netscape.javascript.JSObject; //導入方法依賴的package包/類
public String executeWithResultString(String command) throws FLUIScriptException {
    log("Executing command >>" + command + "<<");
    try {
    	

    	try{
        	//: if console and webView are not set again, the methods are recognized (no error thrown) in JavaScript, but not called!
            JSObject win = (JSObject) webEngine.executeScript("window");
            win.setMember("console", console); 
			win.setMember("webView", webViewCommandHandler);
    	} catch (Exception warning){
    		log("Warning: " + new Exception("Warning: error while setting console and webView (again): " + warning));
    	}
    	
        Object result = webEngine.executeScript(command);
        return (String) result;
    } catch (netscape.javascript.JSException e) {
    	log("Executing command failed: (" + currentScreenID + ") >>" + command + "<<: " + e);
        throw new FLUIScriptException(command, e);
    }
}
 
開發者ID:pheyse,項目名稱:fonotes,代碼行數:22,代碼來源:FLUIWebView.java

示例5: getElevationAlongPath

import netscape.javascript.JSObject; //導入方法依賴的package包/類
/** 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());
    
}
 
開發者ID:MacSimmy,項目名稱:Maps,代碼行數:25,代碼來源:ElevationService.java

示例6: getElevationForLocations

import netscape.javascript.JSObject; //導入方法依賴的package包/類
/** 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);});");
        
//        System.out.println("ElevationService direct call: " + r.toString());
        
        getJSObject().eval(r.toString());
        
    }
 
開發者ID:MacSimmy,項目名稱:Maps,代碼行數:27,代碼來源:ElevationService.java

示例7: getMaxZoomAtLatLng

import netscape.javascript.JSObject; //導入方法依賴的package包/類
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());
        
    }
 
開發者ID:anand9522,項目名稱:MapsApplication,代碼行數:22,代碼來源:MaxZoomService.java

示例8: JavaVersion

import netscape.javascript.JSObject; //導入方法依賴的package包/類
/**
 * Constructs
 */
public JavaVersion() {

	final JSObject objLwindowJSObject = JSObject.getWindow(this);
	final JSObject objLdocumentJSObject = (JSObject) objLwindowJSObject.getMember("document");
	final JSObject objLformsJSObject = (JSObject) objLdocumentJSObject.getMember("forms");
	final JSObject objLformJSObject = (JSObject) objLformsJSObject.getMember("javaVersionApplet");
	final JSObject objLelementsJSObject = (JSObject) objLformJSObject.getMember("elements");
	final JSObject objLjavaVersionJSObject = (JSObject) objLelementsJSObject.getMember("javaVersion");
	objLjavaVersionJSObject.setMember("value", this.getJavaVersion());
}
 
開發者ID:jugglemaster,項目名稱:JuggleMasterPro,代碼行數:14,代碼來源:JavaVersion.java

示例9: connectToWebEngine

import netscape.javascript.JSObject; //導入方法依賴的package包/類
private static void connectToWebEngine(WebEngine engine, String varname) {
    if (	backendObjects.containsKey(engine) &&
            backendObjects.get(engine).containsKey(varname)) {

        JSObject window = (JSObject) engine.executeScript("window");
        window.setMember(varname, backendObjects.get(engine).get(varname));
    }
}
 
開發者ID:jamf,項目名稱:HealthCheckUtility,代碼行數:9,代碼來源:JavaToJavascriptBridge.java

示例10: start

import netscape.javascript.JSObject; //導入方法依賴的package包/類
@Override
public void start(Stage stage) throws Exception {
    WebView view = new WebView();
    WebEngine engine = view.getEngine();
    JSObject win = (JSObject) engine.executeScript("window");
    win.setMember("scriptReady", new ScriptReady());
    engine.load(getClass().getResource(EXTERNAL_PAGE).toExternalForm());
    stage.setScene(new Scene(new BorderPane(view), 640, 480));
    stage.show();
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:11,代碼來源:ExternalResourceLoadingTest.java

示例11: registerEventHandler

import netscape.javascript.JSObject; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:ryanwc,項目名稱:GraphSearch,代碼行數:17,代碼來源:GoogleMap.java

示例12: populateWindowObject

import netscape.javascript.JSObject; //導入方法依賴的package包/類
private void populateWindowObject() {
    JSObject js = (JSObject) view.get().getEngine().executeScript("window");
    js.setMember("__portiaApi", new SpongeJsApi(parentHost, sessionId));
    view.get().getEngine().executeScript(combinedJs+'\n');
}
 
開發者ID:mware-solutions,項目名稱:sether,代碼行數:6,代碼來源:WebUiBrowser.java

示例13: CodeEditor

import netscape.javascript.JSObject; //導入方法依賴的package包/類
public CodeEditor()
{
	webView = new WebView();
	aceEditor = new AceEditor();
	
	codeBodyProperty = aceEditor.getBodyProperty();
	acePageContentsProperty = aceEditor.getPage();
	
	initializeEngineEvents();
	
	webView.getEngine().loadContent(aceEditor.getPage().get());
	
	// Add interface to access Java model from Javascript
	JSObject jsObject = (JSObject) webView.getEngine().executeScript("window");
	jsObject.setMember("javaContentModel", this);
	
	acePageContentsProperty.addListener((observable, old, newValue) -> 
	{
		System.out.println("Loaded:\n" + newValue);
		webView.getEngine().loadContent(newValue);
	});
	
	codeBodyProperty.addListener(
			(observable, old, newValue) -> System.out.println("CodeProperty changed"));
	
	webView.setContextMenuEnabled(false);
	//TODO create custom context menu (right click menu)
	
	// TODO: move this to a js file
	aceEditor.addCustomJavascriptRoutine(() -> "editor.on(\"change\", function() {"
			+ "javaContentModel.updateTextFromJavascript(editor.getValue());"
			+ "});");

	setOnKeyReleased(event -> {
		System.out.println("key released");
		getBreakPoints();
	});

	setCenter(webView);
	this.accessibleRoleProperty().set(AccessibleRole.TEXT_AREA);
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:42,代碼來源:CodeEditor.java

示例14: installServiceLocator

import netscape.javascript.JSObject; //導入方法依賴的package包/類
private void installServiceLocator(ServiceLocator serviceLocator) {
	JSObject windowObject = getJsWindow();
	windowObject.setMember(JS_MEMBER_NAME_APP_SERVICE_LOCATOR, serviceLocator);
}
 
開發者ID:greensopinion,項目名稱:greenbeans,代碼行數:5,代碼來源:WebApplicationRegion.java

示例15: installConsoleBridge

import netscape.javascript.JSObject; //導入方法依賴的package包/類
private void installConsoleBridge() {
	JSObject windowObject = getJsWindow();
	windowObject.setMember(JS_MEMBER_NAME_CONSOLE_BRIDGE, consoleBridge);
	webEngine.executeScript("console.log = function(message) {\nconsoleBridge.log(message);\n};");
}
 
開發者ID:greensopinion,項目名稱:greenbeans,代碼行數:6,代碼來源:WebApplicationRegion.java


注:本文中的netscape.javascript.JSObject.setMember方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。