aboutsummaryrefslogtreecommitdiff
path: root/files/es/archive/web/liveconnect/packages/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/es/archive/web/liveconnect/packages/index.html')
-rw-r--r--files/es/archive/web/liveconnect/packages/index.html44
1 files changed, 44 insertions, 0 deletions
diff --git a/files/es/archive/web/liveconnect/packages/index.html b/files/es/archive/web/liveconnect/packages/index.html
new file mode 100644
index 0000000000..c66265507d
--- /dev/null
+++ b/files/es/archive/web/liveconnect/packages/index.html
@@ -0,0 +1,44 @@
+---
+title: Packages
+slug: Archive/Web/LiveConnect/Packages
+translation_of: Archive/Web/LiveConnect_Reference/Packages
+---
+<p>
+</p>
+<h3 id="Summary" name="Summary"> Summary </h3>
+<p><b>Core Object</b>
+</p><p>A top-level object used to access Java classes from within JavaScript code.
+</p>
+<h3 id="Created_by" name="Created_by"> Created by </h3>
+<p>The <code>Packages</code> object is a top-level, predefined JavaScript object. You can automatically access it without using a constructor or calling a method.
+</p>
+<h3 id="Description" name="Description"> Description </h3>
+<p>The <code>Packages</code> object lets you access the public methods and fields of an arbitrary Java class from within JavaScript. The <code>java</code>, <code>netscape</code>, and <code>sun</code> properties represent the packages <code>java.*</code>, <code>netscape.*</code>, and <code>sun.*</code> 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 <code>Frame</code> class as follows:
+</p>
+<pre class="eval">var theFrame = new Packages.java.awt.Frame();
+</pre>
+<p>For convenience, JavaScript provides the top-level <code>netscape</code>, <code>sun</code>, and <code>java</code> 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:
+</p>
+<pre class="eval">var theFrame = new java.awt.Frame();
+</pre>
+<p>The <code>className</code> property represents the fully qualified path name of any other Java class that is available to JavaScript. You must use the <code>Packages</code> object to access classes outside the <code>netscape</code>, <code>sun</code>, and <code>java</code> packages.
+</p>
+<h3 id="Properties" name="Properties"> Properties </h3>
+<p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Packages/className">className</a>: The fully qualified name of a Java class in a package other than netscape, java, or sun that is available to JavaScript. </p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Packages/java">java</a>: Any class in the Java package java.*. </p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Packages/netscape">netscape</a>: Any class in the Java package netscape.*. </p><p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Packages/sun">sun</a>: Any class in the Java package sun.*.
+</p>
+<h3 id="Examples" name="Examples"> Examples </h3>
+<h4 id="Example:_JavaScript_function_to_create_a_Java_dialog_box" name="Example:_JavaScript_function_to_create_a_Java_dialog_box"> Example: JavaScript function to create a Java dialog box </h4>
+<p>The following JavaScript function creates a Java dialog box:
+</p>
+<pre class="eval">function createWindow() {
+ 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);
+}
+</pre>
+<p>In the previous example, the function instantiates <code>theWindow</code> as a new <code>Packages</code> object. The <code>setSize</code>, <code>setTitle</code>, and <code>setVisible</code> methods are all available to JavaScript as public methods of <code>java.awt.Dialog</code>.
+</p>
+<div class="noinclude">
+</div>