Components can provide events to signal when activity occurs (e.g. button pressed or mouse moved). JFormDesigner shows events in the Events category in the Properties view.
IDE plug-ins: Click on the Go to Method button () to go to the event handler method in the Java editor of the IDE.
Add Event Handlers¶
To add an event handler to a component, right-click on the component in the Design or Structure view and select Add Event Handler from the popup menu. Or click the Add Event button () in the Properties view. The events popup menu lists all available event listeners for the selected components and is divided into three sections: preferred, normal and expert event listeners.
The icon in the popup menu indicates that the listener interface will be implemented (e.g. javax.swing.ChangeListener). The icon indicates that the listener adapter class will be used (e.g. java.awt.event.FocusAdapter for java.awt.event.FocusListener). The icons and are used when the listener is already implemented.
After selecting an event listener from the popup menu, you can specify the name of the handler method and whether listener methods should be passed to the handler method in following dialog.
|If you add a
The "Go to handler method in Java editor" check box is only available in the IDE plug-ins.
Stand-alone: After saving the form, go to your favorite IDE and implement the body of the generated event handler method.
If you use the Runtime Library
and the Java code generator is disabled, you must implement the handler
method yourself in the target class. See
documentation of method
FormCreator.setTarget() in the
JFormDesigner Loader API for
Remove Event Handlers¶
To remove an event handler, click the Remove Event button (). Or right-click on the event and select Remove Event from the popup menu.
Change Handler Method Name¶
You can either edit the method name directly in the property table or click the ellipsis button () to open the Edit Event Handler dialog where you can edit all event options.