EZ Jcom

Java to COM/ActiveX Bridge

EZ Jcom Events Tutorial:  Step one

This tutorial continues from the ActiveX tutorial.  If you have already done that tutorial, you can proceed to the next step.

If you haven’t already done the ActiveX tutorial, go through its first step to generate the EZ JCom framework for the ActiveX, then copy and paste the following code into the Java file c:\ActiveXTest\ActiveXTut.java.  Make sure you can run this code – it will show you a sample ActiveX control, and clicking on the “Test” button will show an About Box.

// Sample ActiveX Tutorial class


import j2c.tutorial.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;


public class ActiveXTut extends JFrame {


  EZJComSampleActiveX activeX;

  JButton button;

  JPanel buttonPanel;



  // This method is called when the Test button is clicked.

  void onButtonClick()


    try {

      // Call the ActiveX’s AboutBox method.


    } catch (Exception ex) {





  void showActiveX()


    try {

      setDefaultCloseOperation( EXIT_ON_CLOSE );

      getContentPane().setLayout( new BorderLayout());


      // Create a container instance and add it to the frame.

      ezjcom.JComActiveXContainer activexContainer =

             new ezjcom.JComActiveXContainer();

      getContentPane().add( activexContainer, BorderLayout.CENTER );

      buttonPanel = new JPanel();

      button = new JButton();

      button.setText( "Test" );

      buttonPanel.add( button );

      getContentPane().add( buttonPanel, BorderLayout.SOUTH );

      button.addActionListener( new ActionListener() {

          public void actionPerformed( ActionEvent e ) { onButtonClick(); }



      // Create the ActiveX object and attach it to the container.

      activeX = new EZJComSampleActiveX();

      activexContainer.setActiveX( activeX );


      // Show the frame.

      setSize( 600, 400 );

      setVisible( true );

    } catch (Exception ex) {





  public static void main( String[] args )


    new ActiveXTut().showActiveX();




Next Step