KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > w3c > dom > events > EventTarget


1 /*
2  * Copyright (c) 2000 World Wide Web Consortium,
3  * (Massachusetts Institute of Technology, Institut National de
4  * Recherche en Informatique et en Automatique, Keio University). All
5  * Rights Reserved. This program is distributed under the W3C's Software
6  * Intellectual Property License. This program is distributed in the
7  * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  * PURPOSE.
10  * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
11  */

12
13 package org.w3c.dom.events;
14
15 /**
16  * The <code>EventTarget</code> interface is implemented by all
17  * <code>Nodes</code> in an implementation which supports the DOM Event
18  * Model. Therefore, this interface can be obtained by using
19  * binding-specific casting methods on an instance of the <code>Node</code>
20  * interface. The interface allows registration and removal of
21  * <code>EventListeners</code> on an <code>EventTarget</code> and dispatch
22  * of events to that <code>EventTarget</code>.
23  * <p>See also the <a HREF='http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113'>Document Object Model (DOM) Level 2 Events Specification</a>.
24  * @since DOM Level 2
25  */

26 public interface EventTarget {
27     /**
28      * This method allows the registration of event listeners on the event
29      * target. If an <code>EventListener</code> is added to an
30      * <code>EventTarget</code> while it is processing an event, it will not
31      * be triggered by the current actions but may be triggered during a
32      * later stage of event flow, such as the bubbling phase.
33      * <br> If multiple identical <code>EventListener</code>s are registered
34      * on the same <code>EventTarget</code> with the same parameters the
35      * duplicate instances are discarded. They do not cause the
36      * <code>EventListener</code> to be called twice and since they are
37      * discarded they do not need to be removed with the
38      * <code>removeEventListener</code> method.
39      * @param typeThe event type for which the user is registering
40      * @param listenerThe <code>listener</code> parameter takes an interface
41      * implemented by the user which contains the methods to be called
42      * when the event occurs.
43      * @param useCaptureIf true, <code>useCapture</code> indicates that the
44      * user wishes to initiate capture. After initiating capture, all
45      * events of the specified type will be dispatched to the registered
46      * <code>EventListener</code> before being dispatched to any
47      * <code>EventTargets</code> beneath them in the tree. Events which
48      * are bubbling upward through the tree will not trigger an
49      * <code>EventListener</code> designated to use capture.
50      */

51     public void addEventListener(String JavaDoc type,
52                                  EventListener JavaDoc listener,
53                                  boolean useCapture);
54
55     /**
56      * This method allows the removal of event listeners from the event
57      * target. If an <code>EventListener</code> is removed from an
58      * <code>EventTarget</code> while it is processing an event, it will not
59      * be triggered by the current actions. <code>EventListener</code>s can
60      * never be invoked after being removed.
61      * <br>Calling <code>removeEventListener</code> with arguments which do
62      * not identify any currently registered <code>EventListener</code> on
63      * the <code>EventTarget</code> has no effect.
64      * @param typeSpecifies the event type of the <code>EventListener</code>
65      * being removed.
66      * @param listenerThe <code>EventListener</code> parameter indicates the
67      * <code>EventListener </code> to be removed.
68      * @param useCaptureSpecifies whether the <code>EventListener</code>
69      * being removed was registered as a capturing listener or not. If a
70      * listener was registered twice, one with capture and one without,
71      * each must be removed separately. Removal of a capturing listener
72      * does not affect a non-capturing version of the same listener, and
73      * vice versa.
74      */

75     public void removeEventListener(String JavaDoc type,
76                                     EventListener JavaDoc listener,
77                                     boolean useCapture);
78
79     /**
80      * This method allows the dispatch of events into the implementations
81      * event model. Events dispatched in this manner will have the same
82      * capturing and bubbling behavior as events dispatched directly by the
83      * implementation. The target of the event is the
84      * <code> EventTarget</code> on which <code>dispatchEvent</code> is
85      * called.
86      * @param evtSpecifies the event type, behavior, and contextual
87      * information to be used in processing the event.
88      * @return The return value of <code>dispatchEvent</code> indicates
89      * whether any of the listeners which handled the event called
90      * <code>preventDefault</code>. If <code>preventDefault</code> was
91      * called the value is false, else the value is true.
92      * @exception EventException
93      * UNSPECIFIED_EVENT_TYPE_ERR: Raised if the <code>Event</code>'s type
94      * was not specified by initializing the event before
95      * <code>dispatchEvent</code> was called. Specification of the
96      * <code>Event</code>'s type as <code>null</code> or an empty string
97      * will also trigger this exception.
98      */

99     public boolean dispatchEvent(Event JavaDoc evt)
100                                  throws EventException JavaDoc;
101
102 }
103
Popular Tags