| Java Gui Builder |
|
||||||||||||||||||
| You are here: | Home > Documentation > JGB Elements Documentation > Register Element |
Group membership: Event-Handling
Registers an event handler for a specific event.
The specific events are specified using class and event. This identifies specific events that the JGB framework will listen for.
When an event is received at one of the ports, the JGB framework will turn around and call the the named method in the specified event manager.
JGB uses Java's Proxy services to provide the necessary framework. This is why the class reference must be an interface.
The methods that will be called in the event manager must follow the following conventions: they must be public, and return a void result. They must have two parameters: a java.util.EventObject, and a jgb.builder.WindowContext. In addition, the method must not throw an exception. JGB does not explicitely catch exceptions so they will propagate to the Swing environment, where they will be caught and logged to the console.
| Name | Type | Required | Description |
|---|---|---|---|
| class | CDATA | Yes |
The interface that describes events that can be generated from this object. The fully qualified class name must be an interface, or the JGB framework will complain with an IllegalArgumentException wrapped in a SAXException. Additionnaly, the interface must not be in the default package. JGB will complain with a SAXException if that is the case. |
| event | CDATA | Yes |
The name of an event upon which to act. This event must be a method declared in the interface named in class. |
| manager | IDREF | Yes |
Determines which object should be notified of an event. This object must have been previously declared in the JGB XML description file. |
| method | CDATA | Yes |
The method that should be called when an event is received. This method must have been declared on the object defined by manager. |
…
<!--
Declare a java.awt.event.ActionListener that will listen for actionPerformed
events and will call the method named "go" on the object saved in the
context's eventManager object.
The declared event manager implementation should look something like this:
import java.util.EventObject;
import jgb.builder.WindowContext;
public class EventManager {
public void go(EventObject event, WindowContext context) {
// Implementation
}
}
-->
<object id="eventManager" class="jgb.examples.WebBrowserEventManager">
<constructor/>
</object>
…
<textfield id="url" reflabel="urllabel">
<register class="java.awt.event.ActionListener" event="actionPerformed" manager="eventManager" method="go"/>
</textfield>
…
|
Hosted on SourceForge.net |
Valid XHTML 1.0 ! |
Valid CSS ! |
Code Coverage provided by Clover |