Before handling events in classes you've imported, see Imported Class Limitations.
-or-
The visual builder generates a placeholder for the method in the .java file.
For example, if your method is getName( ), you would see the following in the .java file:
//{{ extra_code public void getName (java.awt.event.ActionEvent event) { //{{ event_handler // Add your code here } //}} event_handler //}} extra_code
All placeholders for undefined methods are written between the extra_code comments. Once a method is defined, you are free to move it anywhere in the code.
//{{
event_handler
.
IMPORTANT: For the method to be called, Cosmo Code looks for
the argument list(Event-Type event) and the
comments //{{ event_handler
at the beginning and
ending of your method. The argument list must not be
changed, and the comments must stay with the code
definition.
//{{ event_handler
at the beginning and ending of the method.
For example:
public void removeName (java.awt.event.ActionEvent event) { //{{ event_handler int index = nameList.getSelectedIndex(); if (index != -1) { nameList.delItem (index); } } //}} event_handler
IMPORTANT: For the method to be called, Cosmo Code looks for
the argument list(Event-Type event) and the
comments //{{ event_handler
at the beginning and
ending of your method. The argument list must not be
changed, and the comments must stay with the code
definition.
-or-
If you are using a previously defined 1.0.2 method, you'll need to create a 1.1 method using the Object Manager and copy the method body from the 1.0.2 method into the 1.1 method. You may need to do some editing to adjust the syntax.
Note: While you can mix event styles, using only 1.1 style events provides better performance. The only exception to mixing event styles is if you use the same kind of event. For example, if you use a 1.1 event and it's deprecated 1.0.2 equivalent, then only the 1.1 event will ever be triggered.
Guide to the Cosmo Code Development Environment
12-96*527