SampleBean Sample

This sample is located in \Samples\ActiveX\SampleBean.

Description
Using the Sample
Key Project Files
Technologies Demonstrated

Description

This JavaBean handles simple events and can be added as a control to a Microsoft® ActiveX® container, such as Microsoft® Visual Basic® 5.0. The Bean's textToDraw and textColor properties can be set from Visual Basic. The Microsoft virtual machine (Microsoft VM) uses introspection and provides the automatic mapping so that Visual Basic recognizes these as properties of the Bean. The Bean's returnTheDate method can also be called from Visual Basic. The Microsoft VM automatically does all the "wiring" necessary for the somethingHappened method of the SampleBeanEvent to be caught in Visual Basic

You must have Visual Basic 5.0 or later installed to use this sample.

Using the Sample

To compile the sample

Use Nmake.exe to compile the makefile in the \Samples\ActiveX\SampleBean directory.

To use the sample

  1. Run Register.bat to register the Bean. This file runs the javareg utility, which automatically generates the type library needed by Visual Basic.

  2. Open Visual Basic and put the SampleBean.class component in a form

  3. Edit the component. You can set the textToDraw and textColor properties.

Key Project Files

SampleBean.java

This class defines the SampleBeanEventListener interface, registers listeners, and enables and processes mouse events. It also contains methods for getting and setting the textToDraw and textColor properties, and returning the date.

Technologies Demonstrated

ActiveX/Beans

© 1999 Microsoft Corporation. All rights reserved. Terms of use.