dcsimg
Calling a method in the SwingApplet embedded in a page[<EMBED>] from JavaScript in Netscape 4.7.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, January 31, 2002 07:37 PM

function hello() { alert("Applets:"+document.applets.length); alert("Embeds:"+document.embeds.length); alert("byname:"+document.applet1); alert("byID:"+document.appletID1); alert("Embed:"+document.embeds[0]); //document.embeds[0].hello(); } ]]>]]> Hi, I have a problem in calling a Java Swing Applet's method in a HTML page from JavaScript in Netscape Navigator4.7. I am using tag for embedding the applets in html page.I had a HTML input button below the applet and tried to call the Applet's method in its onClick event.After loading the applet , I tried to print the value of document.applets.length is printed as 0 and so I tried to use document.embeds array.Even though document.embeds.length is   More>>
			
Hi,
I have a problem in calling a Java Swing Applet's method in a HTML page from JavaScript in Netscape Navigator4.7.

I am using tag for embedding the applets in html page.I had a HTML input button below the applet and
tried to call the Applet's method in its onClick event.After loading the applet , I tried to print
the value of document.applets.length is printed as 0 and so I tried to use document.embeds array.Even though
document.embeds.length is 1, document.embeds[0] is throwing a JavaScript error saying
"unable to reflect embed with index 0 - not loaded yet?. ".
If I use Applet tag then applet is not showing properly.It shows a message in Status bar saying that
javax/swing/JApplet not found.I think it tries to use the browser's default VM and so it fails.But in Embed tag
by specifying the "type" attribute I can invoke the JRE1.3 plugin directly.So I can't use Applet tag.
Is there any way to specify the browser to use the appropriate plugin , using Applet tag?
I have attached the sample code specifying how I am trying it.copy them to the same directory and open it
in Netscape Navigator4.7.

Browser - Netscape 4.7
Applet - JDK1.3 (Swing Applet)
Plugin - JRE 1.3 Runtime environment

TestApplet.java
--------------------

import javax.swing.JApplet;
import javax.swing.JButton;
import java.awt.FlowLayout;
public class TestApplet extends JApplet
{
public void init()
{
getContentPane().setLayout(new FlowLayout());
getContentPane().add(new JButton("Test Button"));
}

public void hello()
{
System.out.println("hello called");
}
}

TestHtml.html
------------------








CODE = "TestApplet"
CODEBASE = "."
WIDTH = 600 HEIGHT = 300
SCRIPTABLE="true"
MAYSCRIPT="true"
pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html">


alt="Your browser understands the tag but isn't running the applet, for some reason."
Your browser is completely ignoring the tag!






.

   <<Less
About | Sitemap | Contact