Defining GUI actions

To define a GUI action you typically use an ILcdAction. By using an ILcdAction, the functionality of a GUI component is separated from the effect it has on the application. Take, for example, a button that has an ILcdAction associated to it. When the button is pressed by the user, the button calls the method actionPerformed of the ILcdAction. The method actionPerformed has one argument which specifies the event (user interaction) that was invoked on the button. It is then the ILcdAction that defines the effect of this user interaction on the application. As you can see, the button has no direct effect on the application. It merely serves as a messenger that forwards user interaction to the application. The same behavior applies to a menu item in a menu bar.

What is an ILcdAction?

An ILcdAction is an extension of java.awt.event.ActionListener which applies the Command pattern. It is very similar to the Swing javax.swing.Action interface. To create a Swing Action from a given ILcdAction you simply create an instance of TLcdSWAction, which is a Swing wrapper around an ILcdAction.

The interface ILcdAction applies the Listener pattern in collaboration with java.beans.PropertyChangeListener. A PropertyChangeListener accepts java.beans.PropertyChangedEvent objects from the ILcdAction on which it is registered. For more information on listening to changes, refer to Notifying objects of changes with listeners.

Main implementations of ILcdAction

The main implementations of the interface ILcdAction for GXY views are:

Additionally, the sample samples.gxy.common.toolbar.SetProjectionAction shows how to set the ILcdProjection on an ILcdGXYView.