如何将字符串从 Swing 应用程序发送到 javascript?
我正在尝试将字符串从我的 swing 应用程序发送到 javascript,我尝试使用 JSObject sendIt = JSObject.getWindow(this);但我收到以下错误
“因为类 netscape.javascript.JSObject 中的方法 getWindow 无法应用于给定类型; 必需:java.applet.Applet 发现:工作 原因:实际参数 work 无法通过方法调用转换转换为 java.applet.Applet”
下面的代码部分
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
}
}
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
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只能从 Applet 对象中调用 JSObject.getWindow(this),因此“this”应该是对 Applet 对象的引用。
顺便说一句,您应该在小程序标签中启用此功能:
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: