public class Event extends EventObject implements Cloneable
Event
class.Modifier and Type | Field and Description |
---|---|
static EventType<Event> |
ANY
Common supertype for all event types.
|
protected boolean |
consumed
Whether this event has been consumed by any filter or handler.
|
protected EventType<? extends Event> |
eventType
Type of the event.
|
static EventTarget |
NULL_SOURCE_TARGET
The constant which represents an unknown event source / target.
|
protected EventTarget |
target
Event target that defines the path through which the event
will travel when posted.
|
source
Constructor and Description |
---|
Event(EventType<? extends Event> eventType)
Construct a new
Event with the specified event type. |
Event(Object source,
EventTarget target,
EventType<? extends Event> eventType)
Construct a new
Event with the specified event source, target
and type. |
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Creates and returns a copy of this
Event . |
void |
consume()
Marks this
Event as consumed. |
Event |
copyFor(Object newSource,
EventTarget newTarget)
Creates and returns a copy of this event with the specified event source
and target.
|
static void |
fireEvent(EventTarget eventTarget,
Event event)
Fires the specified event.
|
EventType<? extends Event> |
getEventType()
Gets the event type of this event.
|
EventTarget |
getTarget()
Returns the event target of this event.
|
boolean |
isConsumed()
Indicates whether this
Event has been consumed by any filter or
handler. |
getSource, toString
public static final EventTarget NULL_SOURCE_TARGET
protected transient EventTarget target
protected boolean consumed
public Event(EventType<? extends Event> eventType)
Event
with the specified event type. The source
and target of the event is set to NULL_SOURCE_TARGET
.eventType
- the event typepublic Event(Object source, EventTarget target, EventType<? extends Event> eventType)
Event
with the specified event source, target
and type. If the source or target is set to null
, it is replaced
by the NULL_SOURCE_TARGET
value.source
- the event source which sent the eventtarget
- the event target to associate with the eventeventType
- the event typepublic EventTarget getTarget()
public EventType<? extends Event> getEventType()
Event
class can have different event types. These event types further specify
what kind of event occurred.public Event copyFor(Object newSource, EventTarget newTarget)
null
, it is
replaced by the NULL_SOURCE_TARGET
value.newSource
- the new source of the copied eventnewTarget
- the new target of the copied eventpublic boolean isConsumed()
Event
has been consumed by any filter or
handler.true
if this Event
has been consumed,
false
otherwisepublic void consume()
Event
as consumed. This stops its further propagation.public Object clone()
Event
.public static void fireEvent(EventTarget eventTarget, Event event)
eventTarget
- the target for the eventevent
- the event to fireNullPointerException
- if eventTarget or event is nullSubmit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.