本文整理匯總了Java中netscape.javascript.JSObject.call方法的典型用法代碼示例。如果您正苦於以下問題:Java JSObject.call方法的具體用法?Java JSObject.call怎麽用?Java JSObject.call使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類netscape.javascript.JSObject
的用法示例。
在下文中一共展示了JSObject.call方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAttributes
import netscape.javascript.JSObject; //導入方法依賴的package包/類
private void getAttributes(JSObject attributes) {
if (attributes == null) {
atts = new Hashtable<String, String>(0);
return;
}
// load up only the implemented attributes
int nAtts = ((Number) attributes.getMember("length")).intValue();
atts = new Hashtable<String, String>(nAtts);
for (int i = implementedAttributes.length; --i >= 0;) {
Object[] attArgs = { implementedAttributes[i] };
JSObject attNode = (JSObject) attributes.call("getNamedItem", attArgs);
if (attNode != null) {
String attLocalName = (String) attNode.getMember("name");
String attValue = (String) attNode.getMember("value");
atts.put(attLocalName, attValue);
}
}
}
示例2: notifySync
import netscape.javascript.JSObject; //導入方法依賴的package包/類
private String notifySync(String info, String appletName) {
String syncCallback = callbacks[JmolConstants.CALLBACK_SYNC];
if (!mayScript || syncCallback == null)
return info;
try {
JSObject jsoWindow = JSObject.getWindow(appletWrapper);
if (syncCallback.length() > 0)
return "" + jsoWindow.call(syncCallback, new Object[] { htmlName,
info, appletName });
} catch (Exception e) {
if (!haveNotifiedError)
if (Logger.debugging) {
Logger.debug("syncCallback call error to " + syncCallback + ": "
+ e);
}
haveNotifiedError = true;
}
return info;
}
示例3: functionXYZ
import netscape.javascript.JSObject; //導入方法依賴的package包/類
public float[][][] functionXYZ(String functionName, int nX, int nY, int nZ) {
float[][][] fxyz = new float[Math.abs(nX)][Math.abs(nY)][Math.abs(nZ)];
if (!mayScript || nX == 0 || nY == 0 || nZ == 0)
return fxyz;
try {
JSObject jsoWindow = JSObject.getWindow(appletWrapper);
jsoWindow.call(functionName, new Object[] { htmlName,
Integer.valueOf(nX), Integer.valueOf(nY), Integer.valueOf(nZ), fxyz });
} catch (Exception e) {
Logger.error("Exception " + e.getMessage() + " for " + functionName + " with nX, nY, nZ: " + nX
+ " " + nY + " " + nZ);
}
// for (int i = 0; i < nX; i++)
// for (int j = 0; j < nY; j++)
// for (int k = 0; k < nZ; k++)
// System.out.println("i j k fxyz " + i + " " + j + " " + k + " " + fxyz[i][j][k]);
return fxyz;
}
示例4: HTMLWriter
import netscape.javascript.JSObject; //導入方法依賴的package包/類
/**
* When you create a new HTMLWriter, it pops up a new, blank, Web browser
* window to display the output in. You must specify the applet
* (this specifies the main browser window) and the desired size
* for the new window.
**/
public HTMLWriter(Applet applet, int width, int height) {
// Verify that we can find the JSObject class we need. Warn if not.
try { Class c = Class.forName("netscape.javascript.JSObject"); }
catch (ClassNotFoundException e) {
throw new NoClassDefFoundError("HTMLWriter requires " +
"Netscape Navigator 4.0 or higher " +
"or a browser that supports LiveConnect technology");
}
// Get a reference to the main browser window from the applet.
main_window = JSObject.getWindow(applet);
// Create a new window to display output in. This command sends a
// string of JavaScript to the web browser
window = (JSObject)
main_window.eval("self.open(''," +
"'HTMLWriter" + window_num++ + "'," +
"'menubar,status,resizable,scrollbars," +
"width=" + width + ",height=" + height + "')");
// Obtain the Document object of this new window, and open it.
document = (JSObject) window.getMember("document");
document.call("open", null);
}
示例5: HTMLWriter
import netscape.javascript.JSObject; //導入方法依賴的package包/類
/**
* When you create a new HTMLWriter, it pops up a new, blank, Web browser
* window to display the output in. You must specify the applet
* (this specifies the main browser window) and the desired size
* for the new window.
**/
public HTMLWriter(Applet applet, int width, int height) {
// Verify that we can find the JSObject class we need. Warn if not.
try { Class c = Class.forName("netscape.javascript.JSObject"); }
catch (ClassNotFoundException e) {
throw new NoClassDefFoundError("HTMLWriter requires " +
"Netscape Navigator 4.0 or higher");
}
// Get a reference to the main browser window from the applet.
main_window = JSObject.getWindow(applet);
// Create a new window to display output in.
window = (JSObject)
main_window.eval("self.open(''," +
"'HTMLWriter" + window_num++ + "'," +
"'menubar,status,resizable,scrollbars," +
"width=" + width + ",height=" + height + "')");
// Obtain the Document object of this new window, and open it.
document = (JSObject) window.getMember("document");
document.call("open", null);
}
示例6: evaluateCall
import netscape.javascript.JSObject; //導入方法依賴的package包/類
final Object evaluateCall(final Object fn, final Object p) throws InterruptedException, ExecutionException {
FutureTask<?> t = new FutureTask<Object>(new Callable<Object>() {
@Override
public Object call() throws Exception {
JSObject jsRegFn = (JSObject) fn;
return jsRegFn.call("call", null, p);
}
});
ctx.execute(t);
return t.get();
}
示例7: setWeight
import netscape.javascript.JSObject; //導入方法依賴的package包/類
private void setWeight(String weight) {
JSObject win = JSObject.getWindow(this);
String[] args = { weight };
win.call("setWeight", args);
}
示例8: functionXY
import netscape.javascript.JSObject; //導入方法依賴的package包/類
public float[][] functionXY(String functionName, int nX, int nY) {
/*three options:
*
* nX > 0 and nY > 0 return one at a time, with (slow) individual function calls
* nX < 0 and nY > 0 return a string that can be parsed to give the list of values
* nX < 0 and nY < 0 fill the supplied float[-nX][-nY] array directly in JavaScript
*
*/
//System.out.println("functionXY" + nX + " " + nY + " " + functionName);
float[][] fxy = new float[Math.abs(nX)][Math.abs(nY)];
if (!mayScript || nX == 0 || nY == 0)
return fxy;
try {
JSObject jsoWindow = JSObject.getWindow(appletWrapper);
if (nX > 0 && nY > 0) { // fill with individual function calls (slow)
for (int i = 0; i < nX; i++)
for (int j = 0; j < nY; j++) {
fxy[i][j] = ((Double) jsoWindow.call(functionName, new Object[] {
htmlName, Integer.valueOf(i), Integer.valueOf(j) })).floatValue();
}
} else if (nY > 0) { // fill with parsed values from a string (pretty fast)
String data = (String) jsoWindow.call(functionName, new Object[] {
htmlName, Integer.valueOf(nX), Integer.valueOf(nY) });
//System.out.println(data);
nX = Math.abs(nX);
float[] fdata = new float[nX * nY];
Parser.parseStringInfestedFloatArray(data, null, fdata);
for (int i = 0, ipt = 0; i < nX; i++) {
for (int j = 0; j < nY; j++, ipt++) {
fxy[i][j] = fdata[ipt];
}
}
} else { // fill float[][] directly using JavaScript
jsoWindow.call(functionName, new Object[] { htmlName,
Integer.valueOf(nX), Integer.valueOf(nY), fxy });
}
} catch (Exception e) {
Logger.error("Exception " + e.getMessage() + " with nX, nY: " + nX
+ " " + nY);
}
// for (int i = 0; i < nX; i++)
// for (int j = 0; j < nY; j++)
// System.out.println("i j fxy " + i + " " + j + " " + fxy[i][j]);
return fxy;
}
示例9: convertMarkdown
import netscape.javascript.JSObject; //導入方法依賴的package包/類
@FXML
public void convertMarkdown() {
if (view.getEngine().getLoadWorker().getState() != Worker.State.SUCCEEDED) return;
JSObject js = (JSObject) view.getEngine().executeScript("window");
js.call("mark", text.getText());
}
示例10: runTests
import netscape.javascript.JSObject; //導入方法依賴的package包/類
private void runTests() {
JSObject jsWin = (JSObject) webengine.executeScript("window");
jsWin.call("displayTest", new Object[]{null});
JavascriptArray ary = new JavascriptArray();
int len = 0;
for (int i = 0; i < 6; i++) {
len = ary.push("String " + i);
System.out.println("testArrays push " + i + " gives len: " + len);
}
System.out.println("testArrays toString: " + ary.toString());
ary.reverse();
System.out.println("testArrays reverse toString: " + ary.toString());
ary.reverse();
Object obj = ary.pop();
System.out.println("testArrays popped: " + obj);
System.out.println("testArrays popped toString: " + ary.toString());
TestJSO jso = new TestJSO();
jso.setTestName("Test 1");
ary.unshift(jso);
System.out.println("testArrays unshift JsO toString: " + ary.toString());
Object jso1 = ary.shift();
System.out.println("testArrays shift JsO: " + jso1);
System.out.println("testArrays shift JsO reference equality: " + (jso == jso1));
System.out.println("testArrays shift JsO toString: " + ary.toString());
ary.push(jso);
System.out.println("testArrays push JsO toString: " + ary.toString());
jsWin.call("displayArray", ary);
jso.setTestName("Altered Test 1");
jsWin.call("displayArray", ary);
System.out.println("testArrays alter JsO toString: " + ary.toString());
Object jso2 = ary.get(ary.length() - 1);
System.out.println("testArrays get JsO2: " + jso2);
jsWin.call("iterateArray", ary);
jsWin.call("displayTestEnd", new Object[]{null});
}