Adding and Deleting Properties

See Also

Using the WFC Component Builder, you can easily add and delete property definitions in your WFC-based components. A property is typically associated with a private member variable that holds the current property value. Your component then provides public get<PropertyName> and set<PropertyName> methods to retrieve and set the value of the member variable. (A read-only property does not have an associated set<PropertyName> method.) For more information about WFC properties, see WFC Fundamental Programming Concepts.

When you add a property with the WFC Component Builder, the associated member variable and methods are added to your class. The builder also adds the property information to your component's ClassInfo class. ClassInfo allows information about your component to be publicized in a property browser, such as the Properties window.

Note   If your component does not contain a ClassInfo definition, the WFC Component Builder inserts one into your class.

When you delete a property with the WFC Component Builder, the associated ClassInfo entry, member variable, and methods are automatically deleted from your class.

To open the WFC Component Builder

  1. Open your component's source file in the Text editor.

  2. In Class Outline, right-click the name of your class, and then click WFC Component Builder on the shortcut menu.

To add a property

  1. In the Properties pane of the WFC Component Builder, click Add.

  2. In the Property Name box, type the name of the property.

  3. In the Data Type drop-down list, select a data type . (You can enter a class type that is not in the list if the class is on the classpath or available in the Java Package Manager.)

  4. In the Category drop-down list, you can optionally select a category. Categories allow you to group related properties in the Properties window.

  5. Type any description text in the Description box. Property descriptions are displayed in the Properties window.

  6. To make the property read-only, select Read-only Property. (A set<PropertyName> method will not be added to your class.)

  7. To add the associated member variable, select Declare Member Variable. The Associated Member Variable box displays the name for the member variable.

  8. Click Add.

  9. To add another property, repeat the previous steps. (When adding or deleting multiple items in the WFC Component Builder, periodically click Apply to ensure your changes are saved.)

  10. Click OK to close the WFC Component Builder.

To delete a property

  1. In the Properties pane of the WFC Component Builder, select the property you want to delete.

    Note   Deleting a property deletes all associated methods, member variables, and ClassInfo information. Any code that you have added to the methods will be lost. However, you can undo multiple levels of deletion from the Text editor, after the WFC Component Builder is closed. On the Edit menu, click Undo for each deleted item that you want to restore.

  2. Click Delete.

  3. To delete another property, repeat the previous steps. (When adding or deleting multiple items in the WFC Component Builder, periodically click Apply to ensure your changes are saved.)

  4. Click OK to close the WFC Component Builder.