load ActiveX object in Applet

和自甴很熟 提交于 2019-12-06 16:46:24

ActiveX are not supported by an another browser than IE, so there is no way for your application to support all browsers, even on Windows only. An attempt (plugin) to port ActiveX under Firefox 1 was made, but wasn't really useful so as far as I know, there is today no "emulation" solution to your question. Sorry... (see here for Mozilla comments)

JACOB is supposed to let you call COM from Java. It looks like it supports events too.

You can probably access the dlls in the activeX component directly, so you can write a jni wrapper that calls the native functions, and then build a signed applet that can get permission to use jni.

Check this:

http://www.raditha.com/java/jni/

Ahh. You can do want you desire, but may have to eschew Javascript and instead leverage VBScript. It is about the ability to send "events" between two components.

You can use use JavaScript to directly call public methods in the applet or access public variables. JavaScript treats the embedded applet as an object. In the applet tag give the applet a name id.

Consider the example below where the applet has a method public void myMethodInMyApplet();

The HTML page would look something like :

<APPLET CODE="MyApplet.class" 
   width=200 height=200 
   name=counter ID=counter>
</APPLET>

<script type="text/javascript">
    // This is Microsofts javascript way of trapping ActiveX object events.

    function PhilipsSpeechMikeCtrl::SPMEventDeviceConnected(deviceID) {
document.applets[0].myMethodInMyApplet();   
 }
 </script>

Wouldn't that still be Windows- or even IE-dependent, given that Java applets are executed on the client side? Just wondering...

You will obviously have to pass the events twice if you want them to end up in JavaScript.

There is a version of SWT that can be used in applets and can embed ActiveX controls. There are also commercial libraries like Coroutine who can do this as well (and are smaller in jar size). Someone else mentioned JACOB here, which would be another choice.

So, use any of these components to wrap your ActiveX control. These libraries will call a Java method when a registered event occurs.

To pass events from Java to JavaScript, you can use the netscape.javascript.JSObject class which is supported by all major browsers.

If you have the source code for the COM component, it might be a good idea to rewrite it to use JNI, as COM wrappers use up a lot of resources (which is especially important in applets), and most probably there is also some overhead inside the COM component for COM interop.

is activexobjects always hitting the acivex sites like activex.microsoft.com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!