Java with racing stripes

New Look: Sun Microsystems Vice President Rich Green previews a mobile phone prototype with a stylish, functional graphical interface made possible by JavaFX.

John Todd

To compare the recently released JavaFX with Adobe Systems' Macromedia Flash is to miss the point behind Sun Microsystems' development of this new scripting language. JavaFX was designed to give Java users a way to build sexy, modern graphical user interfaces rather than as an enticement to lure Flash users.

It's a good idea. Java programs have rarely caught anyone's eye with visual appeal alone. You know a Java applet when you see one: They tend to be clunky items with little visual flair.

When JavaFX designer Chris Oliver presented the new language at the recent JavaOne conference in San Francisco, he first displayed a PDF reader written in Swing, the standard Java toolkit for user interfaces. It was a boxy Microsoft Windows application, with a bland typeface, no margins around the edges and thumbnails that did nothing if you clicked on them. 'No [user interface] designer would have ever designed this,' Oliver said. He then showed the same application written in JavaFX, a sleek, brushed-metal interface where thumbnails of the PDF pages magically sprang to life as the mouse glided over each page.

In short, Sun wants to give its Java developers the same sorts of design tools that user interface designers enjoy in Adobe Flash or even Illustrator. 'Whatever you see in Flash is possible in Java,' Oliver said. He noted that Java libraries, such as Java 2D and Swing, have long held all the tools needed to build impressive interfaces. It's just that they've been too difficult for developers to dig into, Oliver said.

The JavaFX scripting package includes a combined canvas and text editor, allowing developers to simultaneously review images in the top half of the viewer and their associated code in the bottom half. Changes made in the code can be reflected instantly in the image itself.

The Java libraries have code for building from scratch simple objects such as rectangles, circles ellipses, lines and other objects. All the developer needs to do is change the attributes ' such as shape and color ' of the object to the desired state. Objects can be grouped together so that selected attributes can be set across all of them. Objects can also be set to move about and change shapes, giving programs an animated feel.

And, unlike most scripting languages, JavaFX is statically typed. This means designers enjoy such features as universal code completion and advanced methods such as bind, which cascades a change made in one part of the program to other parts of the program dependent on that section.

About the Author

Joab Jackson is the senior technology editor for Government Computer News.

Stay Connected

Sign up for our newsletter.

I agree to this site's Privacy Policy.