Implementing Event Handler Methods to Support Recording

Because you planned to support recording on the ImageButton control, you suppressed low-level recording on this object, and registered to listen for Action events on this control.

In this section, you implement the actionPerformed listener method, to call MicAPI.record, and record the Click operation on the ImageButton object.

  1. Implement the actionPerformed listener method to record Click operations.

    1. In Eclipse, in the ImageButtonCS.java file, in the actionPerformed listener method stub, modify the code to look like this:

      public void actionPerformed(ActionEvent arg0) 
      {
          try {
                  if (!isInRecord())
                  return;
                  MicAPI.record(arg0.getSource(), "Click");
               } catch (Throwable th) 
                 {
                    MicAPI.logStackTrace(th);
                 }
      }
      
    2. The MicAPI.logStackTrace method prints a stack trace to the log file containing all of the other Java Add-in Extensibility log messages, and allows you to determine when the actionPerformed method was called inadvertently. For more information, see Logging and Debugging the Custom Support Class.

    3. Click the Save button, or select File > Save.

      Note: You do not have to deploy the toolkit support to UFT One again because you changed only Java class files and not configuration files.

  2. Test the new custom support.

    1. Close the SampleApp application and run it again.

    2. Create a new GUI test and click the Record button or select Record > Record. If the Record and Run Settings dialog box opens, make sure the Record and run test on any open Java application option is selected, and click OK. Click the button in the SampleApp application.

      A simple Click operation is recorded on the JavaExt1.gif JavaButton.

The ImageButton custom control is now fully supported, according to the specifications you decided on when planning your custom support

Next steps: