User's Guide

Using your nonvisual part

With your Runner part fully defined, you are now ready to use it in a visual part.

In the VisualAge Organizer, create a visual part named RoadRaceView.

In the Composition Editor, construct a visual part that looks similar to this:
Visual part

Set the settings for the three Text parts as follows:

  1. For the Runner number Text part, set the maxLength property to 3 and set enabled to true. Select converter and then .... In the Converters window, select String for the Data Type, set min to 1, and set defaultObjectFromEmptyString to 100; then select OK.
  2. For the Finish time Text part, set the converter property's Data type to Time, set the data type's timeFormat to 24-hour, and set its showSeconds to true; then select OK in the Converters and Properties windows.
  3. For the Result Text part, set editable to false, reformatOnFocusChange to false, and the converter data type to String.

Add your Runner part as follows:

  1. Select Add Part from the Options menu.
  2. In the Add Part window, type Runner in the Class Name entry field and runner in the Part Name entry field. Then select OK.
  3. Move the pointer over the open space of the free-form surface and click.
    Note:This is the informal way of adding your part to a visual part. You can also formally add your part to the parts palette and use it directly from there. To learn how, see Extending the parts palette.

Select Connect from the runner part's pop-up menu and notice that the three attributes you defined for your part are listed in the dialog: number, finishTime, and runnerAsResultString.

Connect your nonvisual Runner part to your visual parts as follows:

  1. Connect the number attribute of runner to the object attribute of the Runner number Text part.
  2. Connect the finishTime attribute of runner to the object attribute of the Finish time Text part.
  3. Connect the runnerAsResultString event of runner to the object attribute of the Result Text part.
  4. Connect the asResultString attribute of runner to the value parameter of the connection created in Step 3.

When you have made all the connections, your view in the Composition Editor looks like the following:
Connections

Select Save Part from the File menu.

Select Test icon to test your visual part.

Try entering a Runner number of 451 and a Finish time of 13:45:21.

Notice that Result is automatically updated as Runner number and Finish time change. Remember that this is due to the Runner part's global runnerChanged event that refreshes the runnerAsResultString attribute whenever the number or finishTime attributes change. (If the result does not update automatically on your system, click on the Runner number text pane.)

You have now successfully created and used your own nonvisual part.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]