Stephen Chin on WidgetFX and JFXtras
Despite JavaFX being only a little over one month old a number of projects and samples are popping up as developers experiment with Sun's new RIA platform. Amongst this group of early adopters is Stephen Chin, who is the lead developer of two open source JavaFX projects - WidgetFX and JFXtras, and co-author of the forthcoming Pro JavaFX book. InfoQ talks to him to find out more about his projects and his impression of JavaFX in general.
InfoQ: Can you give us a little background about yourself and your development experience?
Sure. I got my start on Java 1.0, building a Java IDE called Sheets for Carnegie Mellon, and have never looked back. My two passions are open-source software and agile development, which has become a very popular combination for developing quality enterprise software. Currently I am a Senior Manager / ScrumMaster at Inovis during the day, and project lead on the WidgetFX and JFXtras open-source projects in my evenings and weekends. Whenever I can break away from my computer I am either racing somewhere on my motorcycle or balancing my very lively daughter on my head.
InfoQ: What capabilities does JFXtras add to the JavaFX release?
The JFXtras project was born out of a conversation between Jim Weaver and I right before the JavaFX 1.0 release about everything we wished JavaFX would have. This included dynamic layouts, dialogs, better asynchronous support, unit testing, and lots more components! Not surprisingly, the JFXtras 0.1 release includes:
- JFXtras Grid - A pure JavaFX declarative grid layout that is designed to be easy to use for simple cases, but supports powerful configuration (including spans, alignment, and grow priority) for complicated layouts.
- JFXStage / JFXDialog - Drop-in replacements for the JavaFX Stage class that give real Java Dialogs, access to the Swing window, and lots of features like alwaysOnTop, pack, etc.
- JFXtras Test - A declarative, fluent, behaviour-driven unit test framework which lets you write tests for JavaFX code in the JavaFX language. Once you get used to the power of declarative testing, it will be hard to go back to plain JUnit.
- JFXWorker - A stopgap solution for asynchronous JavaFX support.
- and plenty more... (check the API docs for the full list)
InfoQ: What are your aims for the JFXtras project going forward?
We are currently cranking on the 0.2 release, which we hope to have out soon. Besides incremental improvements on the Grid and unit testing support, we also have some big new features planned. Andres Almiray of Groovy GraphicsBuilder fame has joined forces and is migrating his jSilhouette shape library to the JFXtras project, which will provide dozens of cool graphics primitives like crosses, stars, balloons, and even a Reuleaux triangle. We will also have the first charting available for JavaFX with a cool pie chart JavaFX component that Ben Jones wrote and was recently featured on Jim Weaver's blog.
Besides this, we have a pretty deep pipeline and an all-star team of top-notch, enthusiastic contributors to make it happen, so expect to see some pretty amazing things over the next few months!
InfoQ: What was the main reason for creating JavaFX Widgets? Where do you see it being used?
InfoQ: There's been a lot of comment in the community about mixing and matching JavaFX and Swing. How easy would it be for me to use a JavaFX Widget in a Swing application?
This is an excellent question, and has come up quite a bit. Embedding Swing in JavaFX is quite easy, and has already been done to create several of the third-party widgets available for WidgetFX, such as Ludovic Hochet's World Clock.
Going the other way and embedding widgets in a Swing application is possible, but you have to use an unsupported component called JXScene that Josh wrote a blog entry about.
InfoQ: What impact do you think JavaFX will have on Swing development?
Declarative GUI programming in JavaFX is quite addictive. Once you get used to the new bind, trigger and animation support, it is hard to go back to the old style of imperative, event-driven UI programming. I believe there will still be a place for Swing to build traditional client UIs, especially until JavaFX matures. However, in the long term, developers will demand the productivity benefits and business will demand the rich user-interface technology that JavaFX provides.
InfoQ: JavaFX Widgets has achieved some interoperability with Flash/Flex. Can you describe this a little and how you achieved it?
I am making use of the JDICplus library developed by Alexey Utkin to provide seamless Flex integration in WidgetFX. It was challenging to reproduce the same user experience as JavaFX, including transparency and draggable widgets, but with a little blood and sweat everything is working.
Probably the biggest limitation right now is platform support. JDICplus is only supported on Windows, which limits the cross-platform capabilities of this feature. It would be great to see Sun endorse Flex integration as a priority for JavaFX and create a simple, cross-platform solution to embed Flash, Flex, and other browser technologies.
InfoQ: What do you see as the key advantages that JavaFX has over alternatives such as Adobe's Flex and Microsoft's Silverlight?
I believe the two strongest advantages of JavaFX are the Java integration and Mobile Platform. For example, the WidgetFX RSS Reader is only 250 lines of code including license, comments and configuration, yet it supports all RSS and Atom flavours known to man. The reason it can be so lightweight is that it takes advantage of the very robust ROME project to provide RSS support, which is an open-source Java API that is trivial to call from JavaFX. No other RIA platform can claim the same breadth of open-source libraries and extensions as Java has today.
Also, the JavaFX Mobile Platform is a deal changer. For a large percentage of developers and businesses, the mobile market has been unreachable due to the complexity and exorbitant cost of developing applications that run on a wide range of devices. I have done some prototyping with the mobile emulator that shipped with the JavaFX 1.0 release, and while it is not complete yet, being able to run the same code as a desktop widget and then moving it straight to the phone is truly amazing!
InfoQ: How do you feel JavaFX is being received in the market?
I think it is too early to tell on this one, but JavaFX has certainly stirred up the development community in an amazing way. I think it is just a matter of time before industry leading sites start taking advantage of JavaFX in ways that no other technology can match.
InfoQ: What IDE do you use when working with JavaFX?
I have primarily been using NetBeans for my JavaFX development, which does a reasonable job of supporting the language given that it is a 1.0 release. I also recently installed the Eclipse JavaFX plug-in and have started working with that. I would also love to see an update to the JavaFX IntelliJ plug-in that showed a lot of promise.
For JavaFX to gain widespread adoption, I believe it is important that all the major IDEs include JavaFX support that is as good as their native Java support. This includes error highlighting, auto code-formatting, searching for usages, cross-language traversal (Java to JavaFX and vice versa), quick javafxdoc, conditional compilation, refactoring (rename, extract method, move package, etc.), templates and code intentions. The different IDE plug-ins support some of the aforementioned list, but none come close to the complete set today.
InfoQ: Have you come across any general issues when working on JFXtras and JavaFX Widgets? If so how did you resolve them?
There have been plenty of little issues along the way in the development of WidgetFX and JFXtras. For instance, while the JFXDialog seems like a simple concept, it actually required several involved workarounds to make it happen that are based on hours of inspecting the decompiled JavaFX code. Fortunately for the users of JFXtras, this is nicely abstracted into a well-documented class that we will maintain as the core JavaFX libraries improve.
Another example is the CacheSafeGroup, which fixes a multi-monitor bug with use of the cache variable on JavaFX Nodes. We filed a defect and the JavaFX team will definitely fix this in a future release, but this was a showstopper for the WidgetFX project so we implemented a reusable workaround that is a drop-in replacement for Group.
InfoQ: How much support have you had from Sun for your projects?
The guys at Sun have been super-busy, but also very supportive. Joshua Marinacci is the official WidgetFX PR guy, and has been doing an excellent job of blogging and getting the word out to the JavaFX community. Also, when I have cornered the JavaFX core team at various events, they enthusiastically listened to all our belly-aching, and even asked for additional feedback to make the JavaFX platform better.
InfoQ: What advice would you give to someone considering adopting JavaFX for an enterprise application now?
A few things that are critical to the success of any commercial JavaFX project are:
- Work very closely with your graphics design team - JavaFX is a completely new model and is not limited by the traditional browser constraints, so it is important to let the design team know the capabilities they can take advantage of, including the new JavaFX Production Suite.
- Get early feedback from your customers - With the new Kernel Installer in JRE 1.6.0_10 it is easier than ever to create a seamless deployment experience. However, if you know in advance that some of the client machines will be limited to an older Java version (such as 1.5), you can target your JavaFX development for that platform.
- Don't reinvent the wheel - JavaFX 1.0 does not come with everything you will need to build a full enterprise application out of the box, but you can take advantage of work being done by third-party projects such as JFXtras (shameless plug) to make sure that you will not be locked in to maintaining a lot of duplicate infrastructure.
InfoQ: What are the main things you want to see for JavaFX over the coming year?
I have an endless wish-list that even old St. Nick wouldn't be able to fit in his sleigh, but some of the more critical ones are:
- Asynchronous Support - JavaFX does not have a clean execution model for execution of long-running background tasks. This is important for developers to write high-performance applications, and ultimately affects the success of the language. The JFXtras JFXWorker is a step in the right direction, but cannot work around some limitations in the core runtime.
- Embedding JavaFX in Java - It would be great to have a fully supported mechanism for embedding JavaFX in Java. Besides providing a migration path for existing Swing applications, this would open up a lot of possibilities for more advanced uses of JavaFX.
- Web 2.0 Integration - The adoption of JavaFX would benefit from the wealth of services and technologies available from the web. As I mentioned earlier, built-in support for Flash and Flex would help, as would integration with mapping services, such as Google Maps. The more JavaFX can bridge the technologies that power the development community today, the more successful the JavaFX platform will be tomorrow.
InfoQ: Anything else you'd like to comment on?
I am very excited about the book that I am collaborating with Jim Weaver and Weiqi Gao on. Jim is probably the most connected man in the JavaFX community today, and Weiqi is an absolute language genius, so between the three of us this is going to be quite an impressive composition. It will definitely be ready in time for JavaOne, so make sure to pick up a copy and come to our sessions!
Caitie McCaffrey Apr 24, 2015