randahl

2 posts

After Oracle announced JavaFX 2.0's return to the Mac earlier this week, I spent some time porting our previously Windows-only JavaFX application back to the Mac. It was surprisingly easy. I found a few bugs, but they turned out to be quite easy to work around. Here's what to watch out for, if you are porting...

1. The Mac API does not use stage.setVisible(true) like the new JavaFX 2.0 Windows API does, instead Mac uses the less flexible (parameterless) stage.show().
2. In the Mac APIs the builder classes are not yet moved to the new builders package, which means we had to change our imports back to statements like import javafx.scene.shape.ArcToBuilder;
3. Unlike the Windows API, the Mac API requires that you remove the leading '/' character in style sheet URLs as in scene.getStylesheets().add("styling/cool.css");
4. The default caspian style-sheet uses blue default buttons in the Mac API, whereas the latest caspian style-sheet on Windows has bright silvery buttons.

Other than that, the combination of the world's best UI framework and the world's best OS is an absolutely amazing development platform.

You can download the new beta for Mac from javafx.com/downloads

These are the days to be a Java UI developer! For so many years I have dreamt of Java’s return to the client side, and now – at long last – the developers at Oracle are making this dream come true. 

Since the late nineties I have been developing a large number of both web based and swing based UIs, and it has always felt like a hard choice between two imperfect sets of technologies. But now – thanks to JavaFX – the days of technological compromise are over.

JavaScript – the slow productivity killer

While my web-based applications would work on more devices, require no installation, and integrate perfectly with the web, too much time was spent debugging the UI and fighting off all those perpetual cross-browser differences. Countless hours were spent trying to make the UI perform and deliver a user experience which ultimately only seemed like the real thing; and as the feature requests from end-users got more demanding in each consecutive project, so got the debugging. “Hey, can we have drag-and-drop? Hey, can we load these data from the desktop? Hey, could we have multi-tasking support?” – Indeed, end-users know the benefits of real native applications – they just do not realize that building a feature-rich UI experience with JavaScript is like building a space shuttle out of papier-mâché... and why should they?

Swing – trusty but overweight

Swing-based Java clients had many benefits over web clients, but at the same time introduced a whole range of new problems. Yes, ditching JavaScript in favor of using real Java all the way from the data access layer to the UI had a sublime impact on code reuse, debug-ability, test-ability, stability, experienced performance, and – most importantly – cost. Still, requiring end-users to download and install applications which were humongous considering the download speeds at the time and Swing’s ever delayed support for HTML beyond HTML 3.0, really put a limit to the kinds of projects which the technology could be applied to. And when customers saw all the luscious visual tricks Adobe pulled out of the hat with Flash, the non-animated, two-dimensional Swing UIs just looked like a steam engine in the space age.

JavaFX – even better than the real thing

JavaFX 1.0 came off to a slow start, mainly because of the surprising decision by Sun – the Java company – to require all Java developers to use a different language than Java when developing the UI, JavaFX Script. I think, Oracle’s most brave and insightful decision after the acquisition of Sun, was to take all the promising, cool features of JavaFX and unleash them in Java with JavaFX 2.0. Gone is JavaFX Script, and now everything Java is also JavaFX and vise-versa. Every single line of code you write can be reused – in all layers of your application. Just imagine the productivity increase your company will harvest from that!

And feature-wise the days of hard compromises are over. Now your compiled, type checked,  automatically unit tested, truly object oriented, highly reusable, component-oriented program is fully capable of rendering real-time, ultra-smooth, CSS styled, vector based 2D and 3D animated contents mixed with video, sound, and (to top it off) HTML contents. – That’s right... all the things you could do in a web client with HTML, you can now do with just a single component in JavaFX (the WebView). And there are hundreds of other rich components in the feature set – if you can conceive it, JavaFX can deliver it.

Getting Started

My company, ROCK IT, is developing an innovative security product for the private sector, and being an Oracle Java partner, I have been using JavaFX since the early access version was released in January. It really is a completely new UI paradigm and it takes a bit of getting used to,  but it is refreshingly innovative and powerful. It truly feels like taking Flash, Swing, and the traditional web technologies, and merging everything into a single, clean, well thought out technology, that matches the needs of the UI layer with perfection.

I am absolutely convinced the developers at Oracle have hit bull’s eye with this technology, and now – at long last – Java lets us creative developers deliver the powerful, rich user interface experience customers want.

If you still have not tried JavaFX, I warmly recommend you get started. The main starting point is http://javafx.com. The JavaFX community forum at http://forums.oracle.com is a great help, and also Jonathan Giles’ blog at http://fxexperience.com/ is a great source of inspiration.

Filter Blog