Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.arcetri.astro.it/irlab/doc/library/javascript/clientreference/packages.htm
Дата изменения: Thu Oct 7 13:13:36 1999 Дата индексирования: Sat Dec 22 14:35:34 2007 Кодировка: Поисковые слова: п п п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п |
Packages
object is a top-level, predefined JavaScript object. You can automatically access it without using a constructor or calling a method.
Packages
object lets you access the public methods and fields of an arbitrary Java class from within JavaScript. The java
, netscape
, and sun
properties represent the packages java.*, netscape.*, and sun.* respectively. Use standard Java dot notation to access the classes, methods, and fields in these packages. For example, you can access a constructor of the Frame
class as follows:
var theFrame = new Packages.java.awt.Frame();For convenience, JavaScript provides the top-level
netscape
, sun
, and java
objects that are synonyms for the Packages
properties with the same names. Consequently, you can access Java classes in these packages without the Packages keyword, as follows:
var theFrame = new java.awt.Frame();The
className
property represents the fully qualified path name of any other Java class that is available to JavaScript. You must use the Packages
object to access classes outside the netscape
, sun
, and java
packages.
Property |
Description
|
|
|
| |
---|
The following JavaScript function creates a Java dialog box:
function createWindow() {In the previous example, the function instantiates
var theOwner = new Packages.java.awt.Frame();
var theWindow = new Packages.java.awt.Dialog(theOwner);
theWindow.setSize(350,200);
theWindow.setTitle("Hello, World");
theWindow.setVisible(true);
}
theWindow
as a new Packages
object. The setSize
, setTitle
, and setVisible
methods are all available to JavaScript as public methods of java.awt.Dialog
.
netscape
, java
, or sun
that is available to JavaScript.Packages.classNamewhere
classname
is the fully qualified name of a Java class.
className
property of the Packages
object to access classes outside the netscape
, sun
, and java
packages.
CorbaObject
class in the myCompany
package from JavaScript:
var theObject = new Packages.myCompany.CorbaObject()In the previous example, the value of the
className
property is myCompany.CorbaObject,
the fully qualified path name of the CorbaObject
class.
java.*
.Packages.java
java
property to access any class in the java
package from within JavaScript. Note that the top-level object java
is a synonym for Packages.java
.
The following code accesses the constructor of the java.awt.Frame
class:
var theOwner = new Packages.java.awt.Frame();You can simplify this code by using the top-level java object to access the constructor as follows:
var theOwner = new java.awt.Frame();
netscape.*
.Packages.netscape
netscape
property to access any class in the netscape
package from within JavaScript. Note that the top-level object netscape
is a synonym for Packages.netscape
.
See the example for .Packages.java
sun.*
.Packages.sun
sun
property to access any class in the sun
package from within JavaScript. Note that the top-level object sun
is a synonym for Packages.sun
.
See the example for .Packages.java
Last Updated: 05/28/99 12:00:08