简体   繁体   中英

How can i send a string from my Swing application to javascript?

i am trying to send a string from my swing application to javascript, i tried using JSObject sendIt = JSObject.getWindow(this); but i get an the following error

"because method getWindow in class netscape.javascript.JSObject cannot be applied to given types; required: java.applet.Applet found: work reason: actual argument work cannot be converted to java.applet.Applet by method invocation conversion"

parts of my code below

public class work extends javax.swing.JFrame {

    private void uploadButtonMouseClicked (java.awt.event.MouseEvent evt) {
        // System.out.println("its here");
        theHash = (String) sender.uploadFunction(filesArray[i], uuid);
        System.out.println("Uploading " + filesArray[i] + "\n");
        JSObject sendIt = JSObject.getWindow(this); //error       
    }
}         

You can only call JSObject.getWindow(this) from within your Applet object, so 'this' should be a reference to an Applet object.

By the way, you should enable this in your applet tag:

<APPLET code="..." width="..." height="..." MAYSCRIPT>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM