Saturday, December 13, 2008

JavaFX and Swing - again

I've noticed that my previous entry about using JavaFX widgets in Swing applications has been getting a lot of traffic since JavaFX 1.0 was finally released.

Having finally had time to download and try out the JavaFX 1.0 SDK it seems like Sun have done a good job: the demos and samples are all good, JavaFX.com no longer looks embarrassing and the NetBeans integration is great (there is an Eclipse plugin available too).

However, the 1.0 release has removed the javafx.ext.swing.Canvas class, which was crucial in embedding JavaFX widgets in Swing applications, as the Canvas had a method to return a JComponent, so you could simply add it to your Swing application without too much trouble. Now I can't see any way of easily using JavaFX in Swing applications - I have heard some hints that it can be done with some reflection 'hacks', but I haven't seen any more information about this.

I hope there is a relatively simple way of achieving this, because if JavaFX really is 'Swing 2' then they need to make the two interoperate as seamlessly as possible so that people can migrate their existing Swing applications in small steps, rather than having to rewrite in JavaFX.

2 comments:

Unknown said...

maybe this will help, a little, while we wait for the clean and official way to do it

http://twitter.com/lqd/status/1060495035

Angel said...

Check this!

http://steveonjava.wordpress.com/2008/12/07/migrating-from-the-javafx-preview-release/