Events
Each java-bean fires its own set of events. Event definitions and Event names are stored in the definition files created by the CPGEN utility. Refer the javadoc of the java-bean for more information about its events.
Event definitions are comment entries with the following structure:
*> eventClass event definitions, Class: classReference.
Event names are level 78 integers.
78 eventName VALUE eventIdValue.
In order to reduce the program complexity, isCOBOL provides the Event-List property, which defines the list of events to be fired. The argument of Event-List is a list of eventClass entries enclosed in parentheses. Each eventClass entry must be enclosed in single or double quotes and is not case-sensitive.
When an event is fired, event-type is set to MSG-JB-EVENT and event-data-2 is set to the event name.
Example:
The sample code has been changed, to instruct the calendar to fire the propertyChange event and handle it in the myDateField-Event paragraph.
...
working-storage section.
...
copy "component.def".
...
screen section.
...
03 myDateField     java-bean
   clsid           "com.toedter.calendar.JDateChooser"
   line            2
   col             2
   size            30
   lines           1.5
   object in       objDateField
   event-list      ("propertyChange")
   event procedure myDateField-Event
The component.def copybook, generated by the CPGEN utility, includes both the event name for the Event-List property (the commented line) and the COBOL contant to be compared with EVENT-DATA-2 in the handling of the MSG-JB-EVENT event:
 *>   PROPERTYCHANGE event definitions, Class: java.beans.PropertyChangeEvent.
 
 78 Component-propertyChange value 681533893.
The event procedure will look like this:
myDateField-Event.
    evaluate event-type
    when msg-jb-event
         evaluate event-data-2
         when Component-propertyChange
              (Imperative statement)
         end-evaluate
    end-evaluate
    .
Some events may return additional information. To retrieve it, the special-names "event source" and "event object" may be defined in the working-storage section of the program.
...
configuration section.
repository.
   class iscobol-java-bean             as "com.iscobol.gui.server.CobolGUIJavaBean"
   class java-event-object             as "java.util.EventObject"
...
working-storage section.
...
77 eventSource is special-names event source object reference iscobol-java-bean.
77 eventObject is special-names event object object reference java-event-object. 
...
No reference to a specific java-bean is made. Like other special-names, event source and event object are automatically handled by isCOBOL.
eventSource is a reference to the built-in object com.iscobol.gui.server.CobolGUIJavaBean and represents the object that fired the event. It provides a convenient and generic way to interact with object firing events.
eventObject is a reference to the standard java object java.util.EventObject, the class from which all event state objects derive. To handle a specific event fired by a java-bean, the reference to that event object must be used.
Example:
...
configuration section.
repository.
   class iscobol-java-bean             as "com.iscobol.gui.server.CobolGUIJavaBean"
   class java-event-object             as "java.util.EventObject"
   class property-change-event         as "java.beans.PropertyChangeEvent"
...
working-storage section.
...
77 eventSource is special-names event source object reference iscobol-java-bean.
77 eventObject is special-names event object object reference java-event-object. 
77 propertyChangeEvent object reference property-change-event. 
77 propertyName pic x any length.
...
myDateField-Event.
    evaluate event-type
    when msg-jb-event
         evaluate event-data-2
         when COMPONENT-PROPERTYCHANGE
              set propertyChangeEvent to eventObject as property-change-event
              set propertyName to propertyChangeEvent:>getPropertyName
              display message "The property " propertyName " has changed."
         end-evaluate
    end-evaluate
    .