ActiveX and Beans Previous
Previous
Welcome
Welcome
Next
Next

Sample Bean

A Bean that handles simple events that could be added to an ActiveX container such as Visual Basic 5.0 as a control. If you have Visual Basic installed, then follow these steps:

  1. Type "register.bat" to register the bean. A type library will automatically be persisted!
  2. Bring up Visual Basic, find the component SampleBean.class, and put it in a form.

Notice that the type library needed by Visual Basic is automatically generated when the javareg utility is run (from the file "register.bat").

The textToDraw and textColor properties of the Bean can be set from Visual Basic. The Microsoft VM for Java uses introspection and provides the automatic mapping so that VB can recognize these as properties of the Bean.

The method "returnTheDate" can also be called from VB.

Lastly the Microsoft VM for Java automatically does all the wiring necessary for the somethingHappened method of the SampleBeanEvent to be caught in VB. So in the code associated with the somethingHappened method in VB, one take some action - and this action will be done in the context of the SampleBeanEvent firing, which in turn happens on mouseDown on the Bean.

Please see the SampleBean.java code.

Remarks:
This bean is meant to be seen is Visual Basic, and is found in the Samples/ActiveXBeans/SampleBean directory.

Top © 1996-1997 Microsoft Corporation. All rights reserved.