Using JWAVE Beans

Using JWAVE Beans with the BeanBox

Step 1: Modify Your CLASSPATH

Step 2: Copy JWaveBeans.jar

Optional: Modify the Startup Script


TIP: You can make the
CLASSPATH modifications described in Step 1 directly in this script, so that CLASSPATH includes $CLASSPATH (UNIX) or %classpath% (Windows).

Step 3: Start the BeanBox


NOTE: You must CD to the BDKDIR/beanbox directory to run run.sh or run.bat. where BDKDIR is the directory in which the BeanBox is installed.

Step 4: Try Out the JWAVE Bean Tester and Surface Tool


NOTE: Remember, the JWAVE Manager must be running to use JWAVE Beans.
  1. From the ToolBox, select JWAVE Bean tester, then click in an open area of the BeanBox window to place it as an object in the BeanBox.
  2. Select a button (such as OrangeButton) from the ToolBox and place it near the bottom of the BeanBox window.
  3. Select the button object in the BeanBox, and then select Edit=Events=button push=actionPerformed.
  4. Click over the JWAVE Bean tester object in the BeanBox. This links the button object to the JWAVE Bean tester object.
  5. In the EventTargetDialog dialog box, select the start2d target method (this method will form the connection between the JWAVE Bean tester and the push button), then click OK. Now, every time you click the button, the tester Bean will generate new 2D data.
Figure 7-1 JWAVE Beans listed in the BeanBox ToolBox
  1. In the ToolBox, select JWAVE Surface Tool and place it above the button object in the BeanBox.
  2. Resize the Surface Tool Bean until it is big enough to hold a surface plot.
  3. Select the JWAVE Bean tester object in the BeanBox, then from the Edit menu, select Events=propertyChange=propertyChange.
  4. Click over the Surface Tool in the BeanBox. This links the Bean tester to the Surface Tool.
  5. In the EventTargetDialog dialog box, select the propertyChange target method as the event, then click OK.
  6. Click the button object in the BeanBox.

Step 4: Customize the Surface Bean


TIP: The customizable parameters for JWAVE Beans are described in
Appendix E, JWAVE Bean Tools Reference.
  1. Select the surface object in the BeanBox, then from the Edit menu, select Events=Customize... The Customizer window for the JWAVE Surface Tool Bean appears.
  2. Change the settings for some of the surface plot's parameters, then click Done.
  3. Click the button in the BeanBox. The surface plot is re-generated and then displayed with the new parameter values applied.
Figure 7-2 The surface plot displayed by the JWAVE Surface Tool. The JWAVE Surface Tool has been customized to add a skirt and change the default colors.

Building a JWAVE Bean


NOTE: The intended audience for this section is Java developers and those familiar with object-oriented programming. This section is by no means a comprehensive source for constructing a Bean. There are many books and Web sites on the subject that take a much more thorough look at the capabilities of JavaBeans.

Deciding What the Bean Will Do

Adding Properties to the Bean

Example 7-1 A get/set pair, taken from JWAVE Bean tester

TIP: Properties do not have to be data members of the class. There can be get/set methods that calculate values or return hardcoded constants.

Handling Data

Using the Proxy Class to Exchange Data

Example 7-2 Data being sent as a Proxy object in JWAVE Bean tester

Using Events to Exchange Data

Example 7-3 Instances of PropertyChangeEvents from JWAVE Bean tester

Including Bound Properties to Exchange New Data

Example 7-4 An input method to the JWAVE Bean tester Bean

Telling a Bean Environment How to Use Your Bean

Using a BeanInfo Class

Example 7-5 BeanDescriptors
Example 7-6 Bean Events
Example 7-7 Bean Methods
Example 7-8 Bean properties

Using Property Editor Classes

Building a Customizer for the Bean

Methods

Example 7-9 Example from a BeanInfo class

TIP: To open a Customizer in the BeanBox, select a Bean and choose Edit=Customize. If the Bean does not have a Customizer, then this option is not available.

Adding Serializability to the Bean


TIP: If you generate an applet from your JWAVE Beans, you must modify the HTML file generated by the BDK. The ARCHIVE tag in the HTML file must include JWave.jar, JWaveBeans.jar, JWaveConnectInfo.jar, and swing.jar.

NOTE: If you want to run your generated applet with appletviewer, you must put the JAR files listed in the previous Tip in your CLASSPATH. This is because appletviewer does not pick up the settings of the ARCHIVE.




Copyright © 1999, Visual Numerics, Inc. All rights reserved.