javafx.scene.input.*Event classes construction

Martin Sladecek martin.sladecek at
Thu Jun 14 03:39:53 PDT 2012

I'd like to discuss possible solutions to the following issue: " Add 
proper constructors & factory methods to event classes, remove impl" ( ).

Current situation is that we have many impl_*event and impl_copy factory 
methods on Event subclasses in javafx.scene.input package. These methods 
exists are called from Scene, which processes events from Quantum a 
creates new Event objects. These methods will be removed and replaced 
with public methods/constructors.

There are 2 main issues that need to be discussed:

#1 - possible ways to construct Event objects
Currently, we have impl_*event methods that have all the possible event 
fields as parameters + impl_copy methods that copies the event with some 
of it's fields modified.

The straightforward solution is to convert impl_*event methods to 
constructors (and possibly add some shorter constructors) and convert 
impl_copy methods to standard public (factory) methods.
One drawback is that we'd have to add more (and bigger) constructors in 
the future, when some other properties are added to events, although 
this is going to happen only really occasionally.

Another possibility is to use builders instead of constructors / factory 
methods and avoid the very long parameters lists. Or at least add them 
for convenience.

#2 - possible use-cases for user-constructed events
I think testing is the most obvious use-case. In the original JIRA 
issue, the use-case was to record the events and then "replay" them 
during the test. This is however not going to work with current API and 
Scene implementation. To replay the events, we would need to let the 
Scene process the events and there's not API for this.

Event.fireEvent applied on a Scene will just send these events to the 
appropriate event handlers, but won't trigger Scene processing that is 
done before these events are normally created in the scene, e.g. drag & 
drop processing.
To support this, Scene event processing would have to be rewritten and a 
new method for passing Event objects to Scene would have to be created.


More information about the openjfx-dev mailing list