Class Event
- java.util.EventObject
-
- javafx.event.Event
All Implemented Interfaces:
Direct Known Subclasses:
ActionEvent, CheckBoxTreeItem.TreeModificationEvent, DialogEvent, InputEvent, ListView.EditEvent, MediaErrorEvent, ScrollToEvent, SortEvent, TableColumn.CellEditEvent, TransformChangedEvent, TreeItem.TreeModificationEvent, TreeTableColumn.CellEditEvent, TreeTableView.EditEvent, TreeView.EditEvent, WebErrorEvent, WebEvent, WindowEvent, WorkerStateEvent
public class Event extends EventObject implements Cloneable
Event class.Since:
JavaFX 2.0
See Also:
-
Field Summary
Fields Modifier and Type Field and Description static EventType<Event>ANYCommon supertype for all event types.protected booleanconsumedWhether this event has been consumed by any filter or handler.protected EventType<? extends Event>eventTypeType of the event.static EventTargetNULL_SOURCE_TARGETThe constant which represents an unknown event source / target.protected EventTargettargetEvent target that defines the path through which the event will travel when posted.-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor and Description Event(EventType<? extends Event> eventType)Construct a newEventwith the specified event type.Event(Object source, EventTarget target, EventType<? extends Event> eventType)Construct a newEventwith the specified event source, target and type.
-
Method Summary
All MethodsStatic MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description Objectclone()Creates and returns a copy of thisEvent.voidconsume()Marks thisEventas consumed.EventcopyFor(Object newSource, EventTarget newTarget)Creates and returns a copy of this event with the specified event source and target.static voidfireEvent(EventTarget eventTarget, Event event)Fires the specified event.EventType<? extends Event>getEventType()Gets the event type of this event.EventTargetgetTarget()Returns the event target of this event.booleanisConsumed()Indicates whether thisEventhas been consumed by any filter or handler.-
Methods inherited from class java.util.EventObject
getSource, toString
-
-
Field Detail
-
NULL_SOURCE_TARGET
public static final EventTarget NULL_SOURCE_TARGET
The constant which represents an unknown event source / target.
-
ANY
public static final EventType<Event> ANY
Common supertype for all event types.
-
eventType
protected EventType<? extends Event> eventType
Type of the event.
-
target
protected transient EventTarget target
Event target that defines the path through which the event will travel when posted.
-
consumed
protected boolean consumed
Whether this event has been consumed by any filter or handler.
-
-
Constructor Detail
-
Event
public Event(EventType<? extends Event> eventType)
Construct a newEventwith the specified event type. The source and target of the event is set toNULL_SOURCE_TARGET.Parameters:
eventType- the event type
-
Event
public Event(Object source, EventTarget target, EventType<? extends Event> eventType)Construct a newEventwith the specified event source, target and type. If the source or target is set tonull, it is replaced by theNULL_SOURCE_TARGETvalue.Parameters:
source- the event source which sent the event
-
-
Method Detail
-
getTarget
public EventTarget getTarget()
Returns the event target of this event. The event target specifies the path through which the event will travel when posted.Returns:
the event target
-
getEventType
public EventType<? extends Event> getEventType()
Gets the event type of this event. Objects of the sameEventclass can have different event types. These event types further specify what kind of event occurred.Returns:
the event type
-
copyFor
public Event copyFor(Object newSource, EventTarget newTarget)Creates and returns a copy of this event with the specified event source and target. If the source or target is set tonull, it is replaced by theNULL_SOURCE_TARGETvalue.Parameters:
newSource- the new source of the copied eventReturns:
the event copy with the new source and target
-
isConsumed
public boolean isConsumed()
Indicates whether thisEventhas been consumed by any filter or handler.Returns:
trueif thisEventhas been consumed,falseotherwise
-
consume
public void consume()
Marks thisEventas consumed. This stops its further propagation.
-
clone
public Object clone()
Creates and returns a copy of thisEvent.
-
fireEvent
public static void fireEvent(EventTarget eventTarget, Event event)Fires the specified event. The given event target specifies the path through which the event will travel.Parameters:
eventTarget- the target for the eventThrows:
NullPointerException- if eventTarget or event is null
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.