www.infoZoom.de 
   

 home  company  jacoZoom  jadoZoom  dataZoom

 jacoZoom  download  buy  samples  support
jacoZoom - Java-COM-Bridge
jacoZoom ActiveX Control Sample : JWeb.java

This sample demonstrates the embedding of an ActiveX Controls in a Swing application by using the jacoZoom-class JActiveX. It is part of the jacoZoom-download and contained in the file JWeb.java.

The ActiveX control used here is the WebBrowser Control also called MS Internet Explorer Control

The following screenshot shows the sample in action:


This sample demonstrates the following tasks:
  • Embedding an ActiveX Control in a Java Swing GUI
  • Manipulating the ActiveX Contro programatically by accessing its specific Automation Interface:
    It calls the WebBrowser's navigate-method to navigate to a web page.
  • Handling events from the ActiveX Control:
    It handles the navigateComplete-event to display the URL of the current page in status bar at the bottom.

The following code snippet shows how it works.
  ...
  com.inzoom.axjni.JActiveX m_jax;
  javax.swing.JLabel m_lblStatus;
  WebEventAdapter m_EventAdapter;
  WebBrowser m_wb;
  ...
  class WebEventAdapter extends DWebBrowserEvents2Adapter {
    public void navigateComplete2(com.inzoom.comjni.IDispatch pDisp,com.inzoom.comjni.Variant[] URL)
      m_lblStatus.setText(URL[0].toString ());
    }
  }
  ...
  m_jax = new com.inzoom.axjni.JActiveX("Shell.Explorer.1");
  frm.getContentPane().add(m_jax,java.awt.BorderLayout.CENTER );
  ...
  m_wb = WebBrowser.getWebBrowserFromUnknown(m_jax.getUnknown());
  m_EventAdapter= new WebEventAdapter();
  m_wb.addDWebBrowserEvents2Listener(m_EventAdapter);
  m_wb.navigate(cstrURLHome);
  ...
  ...
  ...
  ...
  ...