< prev index next >

src/jdk.jsobject/share/classes/netscape/javascript/JSObject.java

Print this page




 132      * Sets an indexed member of a JavaScript object. Equivalent to
 133      * "this[index] = value" in JavaScript.
 134      *
 135      * @param index The index of the array to be accessed.
 136      * @param value The value to set
 137      * @throws JSException when an error is reported from the browser or
 138      * JavaScript engine.
 139      */
 140     public abstract void setSlot(int index, Object value) throws JSException;
 141 
 142     /**
 143      * Returns a JSObject for the window containing the given applet. This
 144      * method only works when the Java code is running in a browser as an
 145      * applet. The object returned may be used to access the HTML DOM directly.
 146      *
 147      * @param applet The applet.
 148      * @return JSObject representing the window containing the given applet or
 149      * {@code null} if we are not connected to a browser.
 150      * @throws JSException when an error is reported from the browser or
 151      * JavaScript engine or if applet is {@code null}




 152      */


 153     public static JSObject getWindow(Applet applet) throws JSException {
 154         return ProviderLoader.callGetWindow(applet);
 155     }
 156 
 157     private static class ProviderLoader {
 158         private static final JSObjectProvider provider;
 159 
 160         static {
 161             provider = AccessController.doPrivileged(
 162                 new PrivilegedAction<>() {
 163                     @Override
 164                     public JSObjectProvider run() {
 165                         Iterator<JSObjectProvider> providers =
 166                             ServiceLoader.loadInstalled(JSObjectProvider.class).iterator();
 167                         if (providers.hasNext()) {
 168                             return providers.next();
 169                         }
 170                         return null;
 171                     }
 172                 }


 132      * Sets an indexed member of a JavaScript object. Equivalent to
 133      * "this[index] = value" in JavaScript.
 134      *
 135      * @param index The index of the array to be accessed.
 136      * @param value The value to set
 137      * @throws JSException when an error is reported from the browser or
 138      * JavaScript engine.
 139      */
 140     public abstract void setSlot(int index, Object value) throws JSException;
 141 
 142     /**
 143      * Returns a JSObject for the window containing the given applet. This
 144      * method only works when the Java code is running in a browser as an
 145      * applet. The object returned may be used to access the HTML DOM directly.
 146      *
 147      * @param applet The applet.
 148      * @return JSObject representing the window containing the given applet or
 149      * {@code null} if we are not connected to a browser.
 150      * @throws JSException when an error is reported from the browser or
 151      * JavaScript engine or if applet is {@code null}
 152      *
 153      * @deprecated  The Applet API is deprecated. See the
 154      * <a href="../../java/applet/package-summary.html"> java.applet package documentation</a>
 155      * for further information.
 156      */
 157 
 158     @Deprecated(since = "9")
 159     public static JSObject getWindow(Applet applet) throws JSException {
 160         return ProviderLoader.callGetWindow(applet);
 161     }
 162 
 163     private static class ProviderLoader {
 164         private static final JSObjectProvider provider;
 165 
 166         static {
 167             provider = AccessController.doPrivileged(
 168                 new PrivilegedAction<>() {
 169                     @Override
 170                     public JSObjectProvider run() {
 171                         Iterator<JSObjectProvider> providers =
 172                             ServiceLoader.loadInstalled(JSObjectProvider.class).iterator();
 173                         if (providers.hasNext()) {
 174                             return providers.next();
 175                         }
 176                         return null;
 177                     }
 178                 }
< prev index next >