Java GUI programs are essentially made of two parts: assembly of GUI components and event handling. Using JudoScript's Java scripting capability, assembling AWT and Swing components is easy. JudoScript uses a special GuiEventsStatement to handle GUI events. This statement can specify event handlers for individual components or a group of components. In the latter case, a named handler is created, which is used by setGuiListener() to assign to specific components. Different GuiEventsStatement's can be used for different sets of components.
For a javax.swing.Timer
object, the event handler is specified the same was
as other GUI components. The Timer
constructor takes a
java.awt.event.ActionListener
instance; in JudoScript this is obtained by
timerHandler(). What really happens is, a JudoScript GUI program has just one
java.awt.event.ActionListener
object, and it routes all the GUI events to the
respective handler code written in JudoScript. timerHandler() returns just that
ActionListener
object.