Class SwingEventAdapter
- java.lang.Object
-
- net.sf.jguiraffe.gui.platform.swing.builder.event.SwingEventAdapter
-
- Direct Known Subclasses:
MouseEventAdapter
public abstract class SwingEventAdapter extends Object
The base class for Swing event adapters.
An event adapter is responsible for transforming a Swing specific event notification into a platform independent form builder event. This base class provides a great deal of common functionality useful for different event types. Concrete sub classes will deal with specific event types.
This base class already stores important information (e.g. about the component this event adapter is associated with) in member fields. It also supports two different ways to map Swing events to platform-independent events:
- If a
FormEventManageris specified, itsfireEvent()method is invoked. This automatically calls all listeners registered for specific or all components. - It is also possible to map the Swing-specific events to a specific event listener which has to be passed to the constructor. In this case only this listener is invoked.
- Version:
- $Id: SwingEventAdapter.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSwingEventAdapter(net.sf.jguiraffe.gui.builder.event.FormEventListener l, net.sf.jguiraffe.gui.forms.ComponentHandler<?> handler, String name)Creates a new instance ofSwingEventAdapterthat serves a specific event listener.protectedSwingEventAdapter(net.sf.jguiraffe.gui.builder.event.FormEventManager eventManager, net.sf.jguiraffe.gui.forms.ComponentHandler<?> handler, String name)Creates a new instance ofSwingEventAdapterthat uses theFormEventManagerto broadcast events.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidfireEvent(net.sf.jguiraffe.gui.builder.event.FormEvent event)Notifies the event manager about a new event.net.sf.jguiraffe.gui.builder.event.FormEventListenergetEventListener()Returns the event listener this adapter is associated with.net.sf.jguiraffe.gui.builder.event.FormEventManagergetEventManager()Returns a reference to the form event manager.net.sf.jguiraffe.gui.forms.ComponentHandler<?>getHandler()Returns a reference to the associated component handler.protected abstract net.sf.jguiraffe.gui.builder.event.FormListenerTypegetListenerType()Returns the event listener type used by this adapter.StringgetName()Returns the name of the component this adapter is registered at.
-
-
-
Constructor Detail
-
SwingEventAdapter
protected SwingEventAdapter(net.sf.jguiraffe.gui.builder.event.FormEventManager eventManager, net.sf.jguiraffe.gui.forms.ComponentHandler<?> handler, String name)Creates a new instance ofSwingEventAdapterthat uses theFormEventManagerto broadcast events.- Parameters:
eventManager- the event manager (must not be null)handler- the component handlername- the component's name- Throws:
IllegalArgumentException- if theFormEventManageris null
-
SwingEventAdapter
protected SwingEventAdapter(net.sf.jguiraffe.gui.builder.event.FormEventListener l, net.sf.jguiraffe.gui.forms.ComponentHandler<?> handler, String name)Creates a new instance ofSwingEventAdapterthat serves a specific event listener.- Parameters:
l- the event listener (must not be null)handler- theComponentHandlername- the name of the component- Throws:
IllegalArgumentException- if the event listener is null
-
-
Method Detail
-
getEventManager
public net.sf.jguiraffe.gui.builder.event.FormEventManager getEventManager()
Returns a reference to the form event manager. This can be null if this adapter is not associated with the event manager.- Returns:
- the event manager
-
getEventListener
public net.sf.jguiraffe.gui.builder.event.FormEventListener getEventListener()
Returns the event listener this adapter is associated with. This can be null if this listener is not associated with an event listener.- Returns:
- the event listener
-
getHandler
public net.sf.jguiraffe.gui.forms.ComponentHandler<?> getHandler()
Returns a reference to the associated component handler.- Returns:
- the component handler
-
getName
public String getName()
Returns the name of the component this adapter is registered at.- Returns:
- the component name
-
fireEvent
protected void fireEvent(net.sf.jguiraffe.gui.builder.event.FormEvent event)
Notifies the event manager about a new event. With this method an event can be sent to all registered listeners.- Parameters:
event- the event to send
-
getListenerType
protected abstract net.sf.jguiraffe.gui.builder.event.FormListenerType getListenerType()
Returns the event listener type used by this adapter. This method must be defined in concrete sub classes.- Returns:
- the event listener type
-
-