Adding Code to Property Methods

The WFC Component Builder creates the methods and fields needed to define and implement your custom properties. Typically, you modify this code to provide your own implementation.

To add code to your property methods

  1. For the getChecked method to return the checked state of the CheckBox control, replace the code that was added by the WFC Component Builder with the following line of code:
    return checkBox1.getChecked();
    
  2. For the setChecked method to set the checked state of the CheckBox control, as well as call other methods that this scenario needs, replace the code that was added by the WFC Component Builder with the following lines of code:
    checkBox1.setChecked(value);
    onCheckedChanged(Event.EMPTY);
    enableControls(this, value);
    

    This code sets the checked state of the CheckBox control based on the value that is passed to the property's method. The code also calls the onCheckedChanged method and makes a call to the enableControls method. The call to the onCheckChanged method triggers a custom event, checkedChanged, which will be added later in this scenario.

    The Event.EMPTY value passed to onCheckedChanged defines an empty Event object to be assigned to the checkedChanged event. The call to the enableControls method is used to enable or disable controls that are added to the GroupCheck control. This method will also be added later in this scenario.

The next step is to add an event to your control.