Class EventRedirector

java.lang.Object
com.sun.javafx.event.BasicEventDispatcher
com.sun.javafx.event.EventRedirector
All Implemented Interfaces:
EventDispatcher

public class EventRedirector extends BasicEventDispatcher
This event dispatcher redirects received events to the registered child dispatchers before dispatching them to the rest of the dispatch chain. The redirected events are wrapped in RedirectedEvent instances, so they can be easily recognized from normal direct events. If an original event wrapped in the RedirectedEvent is consumed by any of the child dispatchers, it won't be sent by the EventRedirector to the rest of the original dispatch chain.

The child dispatchers can also be instances of EventRedirector and might receive both, the normal events (from other sources) and the redirected events from the parent EventRedirector. If a RedirectedEvent is received, it is forwarded to the child event dispatchers without any additional wrapping.

For this hierarchical arrangement of EventRedirector instances the class defines the handleRedirectedEvent method, which is called with a received redirected event, after the event has been forwarded to the child dispatchers. By default this method is empty, but can be overridden in derived classes to define specific handling of these redirected events.

  • Constructor Details

    • EventRedirector

      public EventRedirector(Object eventSource)
      Constructs a new EventRedirector.
      Parameters:
      eventSource - the object for which to redirect the events (RedirectedEvent event source)
  • Method Details

    • handleRedirectedEvent

      protected void handleRedirectedEvent(Object eventSource, Event event)
      Called when a redirected event is received by this instance.
      Parameters:
      eventSource - the object from which the event has been redirected
      event - the event which has been redirected
    • addEventDispatcher

      public final void addEventDispatcher(EventDispatcher eventDispatcher)
    • removeEventDispatcher

      public final void removeEventDispatcher(EventDispatcher eventDispatcher)
    • dispatchCapturingEvent

      public final Event dispatchCapturingEvent(Event event)
      Overrides:
      dispatchCapturingEvent in class BasicEventDispatcher