Documentation

Events

Components can provide events to signal when activity occurs (e.g. button pressed or mouse moved). JFormDesigner shows events in the Structure view and event properties in the Properties view.

Event in Structure view

IDE plug-ins: Double-click on the event in the Structure view 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. 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 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.

Add Event Handler

If you add a PropertyChangeListener, you can also specify a property name (field is not visible in above 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, select it in the Structure view and press the Del key. Or right-click on the event handler and select Delete from the popup menu.

Change Handler Method Name

Select the event handler in the Structure view, press the F2 key and edit the name in-place in the tree. You can also change the handler method and the "pass parameters" flag in the Properties view.