[Contents]   [Index]

The Netscape packages

LiveConnect has the following applet API packages:


The Netscape classes

The netscape.javascript applet API package has the following classes:

The netscape.plugin applet API package has the following classes:

The following sections describe these classes.

netscape.javascript.JSObject

The public final class JSObject extends Object.

java.lang.Object
   |
   +----netscape.javascript.JSObject
JSObject allows Java to manipulate objects that are defined in JavaScript. Values passed from Java to JavaScript are converted as follows:

Values passed from JavaScript to Java are converted as follows:

This means that all JavaScript values show up as some kind of java.lang.Object in Java. In order to make much use of them, you will have to cast them to the appropriate subclass of Object, for example, (String) window.getMember("name") or (JSObject) window.getMember("document").

Methods

The netscape.javascript.JSObject class has the following methods:
Method Description
call(String, Object[])

Calls a JavaScript method

eval(String)

Evaluates a JavaScript expression

finalize()

Decrements the reference count on the corresponding JavaScript object

getMember(String)

Retrieves a named member of a JavaScript object

getSlot(int)

Retrieves an indexed member of a JavaScript object

getWindow(Applet)

Gets a JSObject for the window containing the given applet

removeMember(String)

Removes a named member of a JavaScript object

setMember(String, Object)

Sets a named member of a JavaScript object

setSlot(int, Object)

Sets an indexed member of a JavaScript object

toString()

Converts a JSObject to a string

netscape.javascript.JSException

The public class JSException extends Exception.

java.lang.Object
   |
   +----java.lang.Throwable
           |
           +----java.lang.Exception
                   |
                    +----netscape.javascript.JSException
JSException is an exception that is thrown when JavaScript code returns an error.

Constructors

The netscape.javascript.JSException class has the following constructors:
Constructor Description
JSException()

Constructs a JSException without a detail message

JSException(String)

Constructs a JSException with a detail message

JSException(String, String, int, String, int)

Constructs a JSException with a detail message and all the other info that usually comes with a JavaScript error

netscape.plugin.Plugin

The public class Plugin extends Object.

java.lang.Object
   |
   +----netscape.plugin.Plugin
This class represents the Java reflection of a plugin. Plugins which wish to have Java methods associated with them should subclass this class and add new (possibly native) methods to it. This allows other Java entities (such as applets and JavaScript code) to manipulate the plugin.

Constructors

The netscape.plugin.Plugin class has the following constructors:
Constructor Description
Plugin()

Methods

The netscape.plugin.Plugin class has the following methods:
Method Description
destroy()

Called when the plugin is destroyed

getPeer()

Returns the native NPP object--the plugin instance that is the native part of a Java Plugin object

getWindow()

Returns the JavaScript window on which the plugin is embedded

init()

Called when the plugin is initialized

isActive()

Determines whether the Java reflection of a plugin still refers to an active plugin


Summary of constructors and methods

The applet API package classes have the following constructors and methods:
Syntax Method or Constructor? Class Description
call(String, Object[])

Method

netscape.javascript.JSObject

Calls a JavaScript method

destroy()

Method

netscape.plugin.Plugin

Called when the plugin is destroyed

eval(String)

Method

netscape.javascript.JSObject

Evaluates a JavaScript expression

finalize()

Method

netscape.javascript.JSObject

Decrements the reference count on the corresponding JavaScript object

getMember(String)

Method

netscape.javascript.JSObject

Retrieves a named member of a JavaScript object

getPeer()

Method

netscape.plugin.Plugin

Returns the native NPP object--the plugin instance which is the native part of a Java Plugin object

getSlot(int)

Method

netscape.javascript.JSObject

Retrieves an indexed member of a JavaScript object

getWindow()

Method

netscape.plugin.Plugin

Returns the JavaScript window on which the plugin is embedded

getWindow(Applet)

Static method

netscape.javascript.JSObject

Gets a JSObject for the window containing the given applet

init()

Method

netscape.plugin.Plugin

Called when the plugin is initialized

isActive()

Method

netscape.plugin.Plugin

Determines whether the Java reflection of a plugin still refers to an active plugin

JSException()

Constructor

netscape.javascript.JSException

Constructs a JSException without a detail message

JSException(String)

Constructor

netscape.javascript.JSException

Constructs a JSException with a detail message

JSException(String, String, int, String, int)

Constructor

netscape.javascript.JSException

Constructs a JSException with a detail message and all the other info that usually comes with a JavaScript error

Plugin()

Constructor

netscape.plugin.Plugin

removeMember(String)

Method

netscape.javascript.JSObject

Removes a named member of a JavaScript object

setMember(String, Object)

Method

netscape.javascript.JSObject

Sets a named member of a JavaScript object

setSlot(int, Object)

Method

netscape.javascript.JSObject

Sets an indexed member of a JavaScript object

toString()

Method

netscape.javascript.JSObject

Converts a JSObject to a string


Netscape package reference


call

Method. Calls a JavaScript method. Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript.

Syntax

public Object call(String methodName,
   Object args[])

Method of

netscape.javascript.JSObject


destroy

Method. Called when the plugin is destroyed. You never need to call this method directly, it is called when the plugin is destroyed. At the point this method is called, the plugin will still be active.

Syntax

public void destroy()

Method of

netscape.plugin.Plugin

See also

init


eval

Method. Evaluates a JavaScript expression. The expression is a string of JavaScript source code which will be evaluated in the context given by "this".

Syntax

public Object eval(String s)

Method of

netscape.javascript.JSObject


finalize

Method. Decrements the reference count on the corresponding JavaScript object.

Overrides: finalize in class Object

Syntax

protected void finalize()

Method of

netscape.javascript.JSObject


getMember

Method. Retrieves a named member of a JavaScript object. Equivalent to "this.name" in JavaScript.

Syntax

public Object getMember(String name)

Method of

netscape.javascript.JSObject


getPeer

Method. Returns the native NPP object--the plugin instance which is the native part of a Java Plugin object. This field is set by the system, but can be read from plugin native methods by calling:

NPP npp = (NPP)netscape_plugin_Plugin_getPeer(env, thisPlugin);

Syntax

public int getPeer()

Method of

netscape.plugin.Plugin


getSlot

Method. Retrieves an indexed member of a JavaScript object. Equivalent to "this[index]" in JavaScript.

Syntax

public Object getSlot(int index)

Method of

netscape.javascript.JSObject


getWindow

Method. For netscape.javascript.JSObject, returns a JSObject for the window containing the given applet. For netscape.plugin.Plugin, returns the JavaScript window on which the plugin is embedded.

Syntax

For netscape.javascript.JSObject:

public static JSObject getWindow(Applet applet)
For netscape.plugin.Plugin:

public JSObject getWindow()

Method of

netscape.javascript.JSObject, netscape.plugin.Plugin


init

Method. Called when the plugin is initialized. You never need to call this method directly, it is called when the plugin is created.

Syntax

public void init()

Method of

netscape.plugin.Plugin

See also

destroy


isActive

Method. Determines whether the Java reflection of a plugin still refers to an active plugin. Plugin instances are destroyed whenever the page containing the plugin is left, thereby causing the plugin to no longer be active.

Syntax

public boolean isActive()

Method of

netscape.plugin.Plugin


JSException( )

Constructor. Constructs a JSException without a detail message. A detail message is a String that describes this particular exception.

Syntax

public JSException()

Constructor of

netscape.javascript.JSException


JSException(String)

Constructor. Constructs a JSException with a detail message. A detail message is a String that describes this particular exception.

Syntax

public JSException(String s)

Parameters

s is the detail message.

Constructor of

netscape.javascript.JSException


JSException(String, String, int, String, int)

Constructor. Constructs a JSException with a detail message and all the other info that usually comes with a JavaScript error.

Syntax

public JSException(String s,
   String filename,
   int lineno,
   String source,
   int tokenIndex)

Parameters

s is the detail message.

Constructor of

netscape.javascript.JSException


Plugin

Constructor.

Syntax

public Plugin()

Constructor of

netscape.plugin.Plugin


removeMember

Method. Removes a named member of a JavaScript object.

Syntax

public void removeMember(String name)

Method of

netscape.javascript.JSObject


setMember

Method. Sets a named member of a JavaScript object. Equivalent to "this.name = value" in JavaScript.

Syntax

public void setMember(String name,
   Object value)

Method of

netscape.javascript.JSObject


setSlot

Method. Sets an indexed member of a JavaScript object. Equivalent to "this[index] = value" in JavaScript.

Syntax

public void setSlot(int index,
   Object value)

Method of

netscape.javascript.JSObject


toString

Method. Converts a JSObject to a String.

Overrides: toString in class Object

Syntax

public String toString()

Method of

netscape.javascript.JSObject