简体   繁体   English

如何从我的Swing应用程序向javascript发送字符串?

[英]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); 我正在尝试从我的swing应用程序向javascript发送字符串,我尝试使用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" “因为无法将类netscape.javascript.JSObject中的getWindow方法应用于给定类型;必需:java.applet.Applet被发现:工作原因:实际参数工作不能通过方法调用转换转换为java.applet.Applet”

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. 您只能从Applet对象中调用JSObject.getWindow(this) ,因此“ this”应该是对Applet对象的引用。

By the way, you should enable this in your applet tag: 顺便说一句,您应该在applet标签中启用它:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Swing应用程序中设计“用户首选项”模块? - How can I design User Preferences module in my Swing application? 如何从swing应用程序中调用GWT方法 - how can i call GWT method from swing application 如何将序列化的Java对象从Swing应用程序发送到Google App Engine应用程序,反之亦然? - How do I send serialized java objects from a swing application to a google app engine application and vice versa? JAVA:SWING:如何为Swing应用程序构建.exe - JAVA : SWING : How can i build a .exe for Swing application 如何将简单的消息从网页(HTML / Javascript)发送到Java应用程序? - How can I send simple messages from a webpage (HTML/Javascript) to a Java application? 管理我的 Java Swing 应用程序的快速关键速率,如何在管道的早期删除事件? - fast key rates hosing my Java Swing application, how can I drop events early in the pipeline? 我可以使用iText在我的Swing应用程序中呈现PDF吗? - Can I use iText to render PDF in my Swing application? 如何登录Facebook并获取用户信息以从Android应用程序发送我的远程数据库 - How can I login with facebook and get user info to send my remote db from android application 如何将图像从Java应用程序发送到Android应用程序? - How can I send an Image from a Java application to an Android application? 如何向我的应用程序用户发送确认电子邮件? - How can I send a confirmation email to users of my application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM