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.

Event in Properties view

IDE plug-ins: Click on the Go to Method button (Go to Method) 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 (Add Event) 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.

Add Event Handler menu

The Listener Interface icon in the popup menu indicates that the listener interface will be implemented (e.g. javax.swing.ChangeListener). The Listener Class icon indicates that the listener adapter class will be used (e.g. java.awt.event.FocusAdapter for java.awt.event.FocusListener). The icons Listener Interface implemented and Listener Class implemented 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.

Add Event Handler

If you add a PropertyChangeListener, you can also specify a property name (field is not visible in screenshot). Then the listener is added using the method addPropertyChangeListener(String propertyName, PropertyChangeListener listener).

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 details.

Remove Event Handlers

To remove an event handler, click the Remove Event button (Remove Event). 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 (Edit Event) to open the Edit Event Handler dialog where you can edit all event options.