Question

I am trying to call JavaScript functions from a JApplet. I've searched through tutorials and they say that I need to import and use netscape.javascript.* from my \jre\lib\plugin.jar

I did import netscape.javascript.* and I'm using DrJava, and it kept saying it cannot find the getWindow method.

This is the error it gives me:
(MinesweeperApplet extends JApplet)

Error: cannot find symbol  
    symbol:   method getWindow(MinesweeperApplet)  
    location: class netscape.javascript.JSObject

This is the piece of code inside the MinesweeperApplet class where I am trying to get the JSObject:

public void start(){                
    // add stuff    
    JSObject window = JSObject.getWindow(this);    
    Container cp = getContentPane();
    ...

I appreciate any help. Thanks!

Was it helpful?

Solution

I have found the "solution."

Previously I was using JDK 7. Then I downloaded and tried JDK 6 (update 45) and it could compile fine. And from that point on, the Java-to-Javascript communication works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top