Using Beans in Visual Basic

Now that there are ActiveX wrappers for the Beans in the simulator, let’s create a sample Visual Basic (VB) application that uses them. This is not going to be a tutorial, though you might want to follow along even if you’re not familiar with Visual Basic. This will give you the chance to see one way in which the Beans can be used in an ActiveX environment.

Start up VB and create a project for a standard application. I’m using Version 5 of VB, but the concepts are essentially the same for Version 4. This starts you out with an empty form, as well as a component toolbox with some basic Windows controls to choose from.

In order to make the simulator components available for use on the form, we have to add them into the component toolbox. Go to the Project menu and select the Components item. This launches a dialog box that allows you to identify the components to include in the toolbox for this project, as shown in Figure 11.2. Select the JavaBoiler, JavaCooler, JavaTemperature, and JavaThermostat Bean controls to be added to the toolbox.

Adding Java Beans to the Visual Basic toolbox

Figure 11-2. Adding Java Beans to the Visual Basic toolbox

After you press the OK button, the selected simulator components are added to the VB toolbox, as shown in Figure 11.3. Notice that all four of the simulator components appear in the toolbox using the same icon. This is the default specified by the registry information ...

Get Developing Java Beans now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.