本文整理匯總了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;
}
}
示例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());
}
}
示例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());
}
}
示例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);
}
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}
}
示例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();
}
示例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);
}
示例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');
}
示例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);
}
示例14: installServiceLocator
import netscape.javascript.JSObject; //導入方法依賴的package包/類
private void installServiceLocator(ServiceLocator serviceLocator) {
JSObject windowObject = getJsWindow();
windowObject.setMember(JS_MEMBER_NAME_APP_SERVICE_LOCATOR, serviceLocator);
}
示例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};");
}