org.bushe.swing.event
Class ContainerEventServiceAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.bushe.swing.event.EventServiceAction
          extended by org.bushe.swing.event.ContainerEventServiceAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action

public class ContainerEventServiceAction
extends EventServiceAction

When fired, this action publishes an ActionEvent on a Container EventService. See EventServiceAction for more information.

By default, the Container EventService is found by asking the ContainerEventServiceFinder to find the EventService for the source of the fired ActionEvent, which must be a java.awt.Component and contained in a hierarchy (the source must have been added to another Swing container). If the action was on a button, this means the container hierarchy of the button is walked (up) until a ContainerEventServiceSupplier is found or until the top of the hierarchy is reached, at which point a ContainerEventService is created automatically on the fly via the top container's putClientProperty() method using the key ContainerEventServiceFinder.CLIENT_PROPERTY_KEY_TOP_LEVEL_EVENT_SERVICE. If the event is from a JPopupMenu then the popup menu's invoker's hierarchy is walked.

To exhibit other behavior, override the getSwingEventService() to return another EventService. For example, the creator of a popup menu may pass itself to the ContainerEventServiceFinder to return a parent's EventService.

See Also:
for further documentation, on how the service is found, Serialized Form

Field Summary
 
Fields inherited from class org.bushe.swing.event.EventServiceAction
EVENT_BUS_EVENT_CLASS_NAME, EVENT_SERVICE_TOPIC_NAME
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
ContainerEventServiceAction()
           
ContainerEventServiceAction(String actionName, ImageIcon icon)
           
 
Method Summary
protected  EventService getEventService(ActionEvent event)
          Override to return the EventService on which to publish.
 
Methods inherited from class org.bushe.swing.event.EventServiceAction
actionPerformed, getEventServiceEvent, getName, getThrowsExceptionOnNullEventService, getTopicName, getTopicValue, isPublishesOnTopic, setPublishesOnTopic, setThrowsExceptionOnNullEventService, setTopicName
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainerEventServiceAction

public ContainerEventServiceAction()

ContainerEventServiceAction

public ContainerEventServiceAction(String actionName,
                                   ImageIcon icon)
Method Detail

getEventService

protected EventService getEventService(ActionEvent event)
Description copied from class: EventServiceAction
Override to return the EventService on which to publish.

Specified by:
getEventService in class EventServiceAction
Parameters:
event - the event passed to #execute(ActionEvent)
Returns:
the event service to publish on, if null and getThrowsExceptionOnNullEventService() is true (default) an exception is thrown
See Also:
EventBusAction, ContainerEventServiceAction


Copyright © 2011 Bushe Enterprises, Inc.. All Rights Reserved.