Basic HTML version of Foils prepared May 19 99

Foil 18 Using the BeanBox to Link Beans via Events

From Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. by Geoffrey Fox, Nancy McCracken, Wojtek Furmanski


The BeanBox can also be used to make a new bean from existing beans which uses components to control another bean. The event handler of the component can call a method in the other bean.
Consider the standard example of hooking up two buttons to start and stop the Juggler animation bean.
  • First we place a button and name it start. We want to hook up its actionEvent with the method called startJuggling() in the Juggler, which starts the animation.
  • The BeanBox allows us to select the actionPerformed event from the "button push" menu, select the Juggler bean to be the target, and select its startJuggling method.
  • What this does is to create a class that implements an ActionListener (or inherits from the ActionListener adapter class).
The code created for this bean can be saved as a new bean.



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Mon Jul 5 1999