Ok, your project is in need of one or more database editors, and we are going to add them to it right now!

Adding a MaxBase Bean into the Visual Composition Editor (the white space where you assemble beans and code) is quite easy: just select the Bean category where you stored the MaxBase bean, and the following new icon will appear there:

Select it and then click where you want it to be placed, like in the picture (where the newly created MaxBase instance has been named 'Arti'):

By the way, the window "Mimages: prototipo" that you see in the above picture is not distributed with MaxBase, because it was taken from a project of mine. Its only purpose is to let us see how to make MaxBase and the rest of your project coexhist and interact.

At this point 'Arti' would still not show, if we ran the program, because Visual Age for Java doesn't know how and when to instantiate MaxBase. What we want to do is to intercept an event, the pressing of the button 'Lancia', in order to attach to it an action, the instantiation and customization of the Arti bean. Under Visual Age for Java, this task is accomplished by right-clicking on the button, and choosing 'Connect -- actionPerformed'; a dashed line will appear: move the mouse over Arti and click on it, then you will be prompted with a number of possible methods to call via a pop up menu.

None of the properties and methods of interest to us (for this example) are in that menu, so we must select "All Features..." like in the following picture.

Shortly thereafter a window will appear, prompting us to select a method, event or property to be called when the pressing of the button 'Lancia' happens.

The first method to call would be the default constructor, MaxBase(), but since VisualAge for Java automatically instantiates the beans when they are first used, we can safely skip that step. We choose the activeDB property instead. At this point Visual Age for Java will create a path between the button 'Lancia' and 'Arti', but the line will remain dashed meaning that a parameter is still missing. We can directly supply the required parameter (that tells MaxBase which database to open) or connect the dashed line to the value of the text field to let the user change the location where to look for a database (as I did later in my project).

If we ran the example at this point, we would have the 'Mimages: prototipo' window spawning the MaxBase instance (Arti) after the 'Lancia' button has been pressed. Mission accomplished!

 


Max Marsiglietti © 1997
Layout and artwork Andrea Resmini 1997