-
Sub-task
-
Resolution: Delivered
-
P4
-
jfx21
Four new default methods were added to the `javafx.event.EventTarget` interface:
```
<E extends Event> void addEventHandler(EventType<E>, EventHandler<? super E>)
<E extends Event> void removeEventHandler(EventType<E>, EventHandler<? super E>)
<E extends Event> void addEventFilter(EventType<E>, EventHandler<? super E>)
<E extends Event> void removeEventFilter(EventType<E>, EventHandler<? super E>)
```
This change allows applications to manage event handlers for all `EventTarget` implementations.
Most applications will not run into any backward compatibility problems with this change. The change is fully binary compatible and, for most use cases, it is also source compatible.
A compilation error will occur in one of the following two unlikely cases:
* An application class extends `Menu`, `MenuItem`, `TableColumnBase`, or `TreeItem`, and overrides `addEventHandler` or `removeEventHandler`
* An application class that is not a subclass of `Node` implements their own `addEventHandler` or `removeEventHandler` using a signature other than that of the newly added methods (for example, copying the same incorrect pattern that `MenuItem` used prior to this release)
In these cases, the declared methods must be changed to conform to the updated interface method signature.
```
<E extends Event> void addEventHandler(EventType<E>, EventHandler<? super E>)
<E extends Event> void removeEventHandler(EventType<E>, EventHandler<? super E>)
<E extends Event> void addEventFilter(EventType<E>, EventHandler<? super E>)
<E extends Event> void removeEventFilter(EventType<E>, EventHandler<? super E>)
```
This change allows applications to manage event handlers for all `EventTarget` implementations.
Most applications will not run into any backward compatibility problems with this change. The change is fully binary compatible and, for most use cases, it is also source compatible.
A compilation error will occur in one of the following two unlikely cases:
* An application class extends `Menu`, `MenuItem`, `TableColumnBase`, or `TreeItem`, and overrides `addEventHandler` or `removeEventHandler`
* An application class that is not a subclass of `Node` implements their own `addEventHandler` or `removeEventHandler` using a signature other than that of the newly added methods (for example, copying the same incorrect pattern that `MenuItem` used prior to this release)
In these cases, the declared methods must be changed to conform to the updated interface method signature.