Josh Fruhlinger
Contributing Writer

JavaFX is coming to your phone

how-to
Feb 19, 20093 mins

Oh, hey, I haven’t mentioned it but JavaFX 1.1, which includes the much anticipated mobile functionality, has arrived. Sun’s Java ME director Eran Davidov gave an interesting interview to the Artima Developer Spotlight Forum on how you can write JavaFX code that works across various platforms. This is the bit that I found most interesting:

You just have one version of a JavaFX application, and then apply some logic in your application to determine what differences will be present given different display sizes, for example. That logic will scale the same application to different phone sizes. You won’t be creating an LG application versus a Sony-Ericcson application, or different versions based on screen sizes or other device factors. That is different from what we have in Java ME. With JavaFX, we are hiding a lot of the device-based fragmentation by providing a layer that works across all those devices.

Ah, writing once, running anywhere! What a concept!

There’s also a review from The Register, and because it’s The Register, you know it’s going to be snide, right? Still, among the funny but cheap shots (“Another mobile demo impressively shows how Java Micro Edition now provides access to your mobile phone’s accelerometer. Developers will soon be swinging their phones like Wiimotes while the garbage collector stutters to catch up.”), El Reg does come up with a key point that I hadn’t seen spelled out so baldly elsewhere:

However, some notes casually buried away in the 1.1 release notes suggest otherwise: the javafx.ext.Swing package isn’t available in the common profile so won’t work in mobile applications – this means no standard desktop UI components such as buttons, trees and listboxes. You do get one component, javafx.scene.control.TextBox. But the richness of the desktop component set just isn’t there in the mobile configuration. When you look at the existing mobile demos, you’ll quickly realize the colorful, motion-blurred, willy waving – such as a custom image masquerading as a button – divert attention from the lack of GUI components.

Yes, we’ve known all along that you need to build to the Common profile if you want to run on a mobile device; but if easy-to-use UI components aren’t part of that API, doesn’t that defeat the whole purpose of the very UI-centric JavaFX? More UI controls will be hitting the Common profile before JavaOne 2009, but until then mobile developers might find things a little half-baked. The Register does point out one saving grace: unlike the situation on the desktop, JavaFX mobile does not particularly lag offerings from Adobe (whose Flash Light isn’t in wide use) or Microsoft (which doesn’t even have a real mobile version of Silverlight yet).