从 Flex 调用 Java Applet
我正在开发 Flex 应用程序,我需要从 Flex 打开一个 Java Applet(例如单击按钮)。我特别想打开 imageJ,这是一个特定的成像程序,可以作为应用程序、小程序或集成在网页中。有没有办法从 Flex 调用它?我看过一些教程,解释了如何从 Flex 调用另一个 Java 文件中的单个函数,但我不太确定这就是我正在寻找的内容。 感谢您的回答, 干杯,
大卫
I'm working on Flex application and I need to open a Java Applet from Flex (e.g. clicking a button). In particular I'd like to open imageJ, a particular imaging program that could work as application, applet or be integrated in a web page. Is there a way to call it from Flex? I've seen a couple of tutorials that explain how to call a single function in another Java file from Flex, but I'm not so sure that it is what I'm looking for.
Thanks for your answers,
cheers,
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道是否有更好的方法,但如果我这样做,我会编写一个 JavaScript 函数来加载 Java 小程序(可能像
document.write("
I don't know if there's a better way, but if I was doing it, I'd write a JavaScript function that would load the Java applet (could be as simple as
document.write("<object …>")
), then use Flex's ExternalInterface to call that JavaScript.在小程序中公开一个公共方法,Flex 将调用该方法。您可以通过以下方式加载小程序。这是一个示例程序,调用java方法并从java获取值,您可以根据您的需要进行更改
通过您的html文件中的上述内容(我不会解释所有内容),小程序将被下载并准备使用。现在,单击 Flex 应用程序上的按钮,您应该看到如下所示的内容。
注意:MyApplet是上面对象声明中的名称,functionInJava是java类com.my.applet.MyApplet中的公共函数。它接受一个参数并返回一个字符串参数。 Java 程序如下所示。
快乐编码。
Expose a public method in your applet, which the flex would call. You could load the applet the following way. It is a sample program, to call java methods and get a value from java, you can do changes as per your need
With the above in your html file( I am not explaining everything) , the applet will be downloaded and ready to use. Now on click of a button on your flex app, you should have something like below.
Note : MyApplet is the name in the object declaration above, the functionInJava is a public function in the the java class com.my.applet.MyApplet. It takes a parameter and returns a string parameter. The Java program will look like below.
Happy coding.