233 * object is converted to the original wrapped JavaScript object.
234 * Otherwise a {@code JavaRuntimeObject} is created. This is
235 * a JavaScript object that acts as a proxy for the Java object,
236 * in that accessing properties of the {@code JavaRuntimeObject}
237 * causes the Java field or method with the same name to be accessed.
238 *
239 * <h4>Calling back to Java from JavaScript</h4>
240 *
241 * <p>The {@link netscape.javascript.JSObject#setMember JSObject.setMember}
242 * method is useful to enable upcalls from JavaScript
243 * into Java code, as illustrated by the following example. The Java code
244 * establishes a new JavaScript object named {@code app}. This object has one
245 * public member, the method {@code exit}.
246 * <pre><code>
247 public class JavaApplication {
248 public void exit() {
249 Platform.exit();
250 }
251 }
252 ...
253 JSObject window = (JSObject) webEngine.executeScript("window");
254 window.setMember("app", new JavaApplication());
255 * </code></pre>
256 * You can then refer to the object and the method from your HTML page:
257 * <pre><code>
258 <a href="" onclick="app.exit()">Click here to exit application</a>
259 * </code></pre>
260 * <p>When a user clicks the link the application is closed.
261 * <p>
262 * If there are multiple Java methods with the given name,
263 * then the engine selects one matching the number of parameters
264 * in the call. (Varargs are not handled.) An unspecified one is
265 * chosen if there are multiple ones with the correct number of parameters.
266 * <p>
267 * You can pick a specific overloaded method by listing the
268 * parameter types in an <q>extended method name</q>, which has the
269 * form <code>"<var>method_name</var>(<var>param_type1</var>,...,<var>param_typen</var>)"</code>. Typically you'd write the JavaScript expression:
270 * <pre>
271 * <var>receiver</var>["<var>method_name</var>(<var>param_type1</var>,...,<var>param_typeN</var>)"](<var>arg1</var>,...,<var>argN</var>)</code>
272 * </pre>
273 *
274 * <h4>Threading</h4>
275 * <p>{@code WebEngine} objects must be created and accessed solely from the
276 * JavaFX Application thread. This rule also applies to any DOM and JavaScript
277 * objects obtained from the {@code WebEngine} object.
278 * @since JavaFX 2.0
279 */
280 final public class WebEngine {
|
233 * object is converted to the original wrapped JavaScript object.
234 * Otherwise a {@code JavaRuntimeObject} is created. This is
235 * a JavaScript object that acts as a proxy for the Java object,
236 * in that accessing properties of the {@code JavaRuntimeObject}
237 * causes the Java field or method with the same name to be accessed.
238 *
239 * <h4>Calling back to Java from JavaScript</h4>
240 *
241 * <p>The {@link netscape.javascript.JSObject#setMember JSObject.setMember}
242 * method is useful to enable upcalls from JavaScript
243 * into Java code, as illustrated by the following example. The Java code
244 * establishes a new JavaScript object named {@code app}. This object has one
245 * public member, the method {@code exit}.
246 * <pre><code>
247 public class JavaApplication {
248 public void exit() {
249 Platform.exit();
250 }
251 }
252 ...
253 JavaApplication javaApp = new JavaApplication();
254 JSObject window = (JSObject) webEngine.executeScript("window");
255 window.setMember("app", javaApp);
256 * </code></pre>
257 * You can then refer to the object and the method from your HTML page:
258 * <pre><code>
259 <a href="" onclick="app.exit()">Click here to exit application</a>
260 * </code></pre>
261 * <p>When a user clicks the link the application is closed.
262 * <p>
263 * Note that the property value {@code javaApp} of
264 * JavaScript object named {@code app} is implemented as Weak Global Reference.
265 * <pre><code>
266 JSObject window = (JSObject) webEngine.executeScript("window");
267 window.setMember("app", new JavaApplication());
268 * </code></pre>
269 * <p>
270 * Hence if the property value is a local object {@code "new JavaApplication()"}, the value will be GC'ed in next
271 * GC Cycle.
272 * <pre><code>
273 <a href="" onclick="app.exit()">Click here to exit application</a>
274 * </code></pre>
275 * <p>
276 * When a user clicks the link, it does not guarantee to execute the callback method {@code exit}.
277 * <p>
278 * If there are multiple Java methods with the given name,
279 * then the engine selects one matching the number of parameters
280 * in the call. (Varargs are not handled.) An unspecified one is
281 * chosen if there are multiple ones with the correct number of parameters.
282 * <p>
283 * You can pick a specific overloaded method by listing the
284 * parameter types in an <q>extended method name</q>, which has the
285 * form <code>"<var>method_name</var>(<var>param_type1</var>,...,<var>param_typen</var>)"</code>. Typically you'd write the JavaScript expression:
286 * <pre>
287 * <var>receiver</var>["<var>method_name</var>(<var>param_type1</var>,...,<var>param_typeN</var>)"](<var>arg1</var>,...,<var>argN</var>)</code>
288 * </pre>
289 *
290 * <h4>Threading</h4>
291 * <p>{@code WebEngine} objects must be created and accessed solely from the
292 * JavaFX Application thread. This rule also applies to any DOM and JavaScript
293 * objects obtained from the {@code WebEngine} object.
294 * @since JavaFX 2.0
295 */
296 final public class WebEngine {
|