Multi-touch API

Richard Bair richard.bair at oracle.com
Wed May 30 17:14:45 PDT 2012


>> Here's some code written from memory for javaFX
>> 
>>   touchSupport = new JavaFxTouchSupport(jfxAppFrame);
>> 
>>   touchSupport.addListener(fooNode, new PinchZoomRecogniser(new PinchZoomListener() {
>>      public void beginZoom(event) {
>>      }
>>      public void updateZoom(event) {
>>      }
>>      public void finishZoom(event) {
>>      }
>>   }));
> 
> I'll just state here that having API similar to Swing is not a goal of FX.

Ya, specifically Swing / AWT used this interface-with-multiple-methods approach to event handlers / listeners, whereas JavaFX uses a property for each event handler. This was done for multiple reasons. One was that mapping this onto a property language feature would be really quite nice (at least, it seems to be so :-)). Another reason is that it means when we get lambda's in Java, you can use lambda's for event handlers, whereas if we had gone with the interface-with-multiple-methods then we wouldn't be able to use lambdas. Also from other languages which have lambdas / closures, the property-per-event design allows them to use those lambdas / closures quite naturally.

Thanks!
Richard


More information about the openjfx-dev mailing list