Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I add multi-touch gestures to a desktop swing application?  RSS feed

 
Gary W. Lucas
Ranch Hand
Posts: 67
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have access to a Windows-based PC with a large touch-based display and would like to adapt a desktop application to run on it. The application is based on a classic Swing interface and actually runs fine as is. But, since it is a touch-based device, I'd like to enhance the application to support multi-touch gestures such as the pinch to zoom, rotate, etc.

Does Java/Swing have any support for this nowadays? I've done a bit of searching, but haven't had any luck.

Thanks.

Gary

 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaFX is the current GUI for Java, and it has touch events.
I'm not sure Swing gets much development love nowadays at Oracle.

It is possible to integrate JavaFX into a Swing app, though.
See:
http://docs.oracle.com/javafx/2/swing/swing-fx-interoperability.htm

That way you might be able to make use of the touch stuff.
 
Gary W. Lucas
Ranch Hand
Posts: 67
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, that was a fast reply!

I wondered if it might come down to JavaFX.

Having been inside the Swing code a bit, I can't imagine that making it interoperable with a new module like JavaFX would have been a easy job for Sun/Oracle. Do you have any experience mixing the two? Is it stable? Are there any "gotchas" I should be wary of?

Thanks again.

Gary

 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never done it I'm afraid.

That page seems to cover a lot of options, but I expect it all comes down to the structure of the project you are attempting to put this into.
It looks like a case of juggling the two threads, the EDT for Swing and the FX thread for FX.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!