Wednesday, March 31, 2010


For new project, I need to create desktop UI. Of course there is good old Swing, but it is good known for his flaws and it is always interesting to pick something new and sexy. JavaFX got some buzz lately, so I decided to try it.

There are several installation of JavaFX, I decided to go with simple SDK. Installation was ok, I had to update my JDK to 6u18. From development process perspective I was not expecting anything fancy, nice Ant task to compile files was completely sufficient. Compiled code runs simply by Java runtime, no special tools needed - just bunch of new libs. So there is little overhead over any classic Swing application, that can run on plain JDK.

JavaFX has it's own language, which looks like some mix between JSON (visually) and HTML (idea), plus it can hold scripts. Language is quite ok, but in my opinion desktop requires more separation between layout, styles and code like in web development, but here again everything is mixed like in Swing. But anyway, language is quite ellegant and is easily understood.

Stage {
    title: "Test"
    scene: Scene {
        width: 300
        height: 250
        content: [
          VBox {translateX: 10 translateY: 10 spacing: 20
                content: [
                     HBox {spacing: 5
                       content: [
                         Label {text: "Field:"}
                         Button {text: "Button1" strong: true }
                         Button {text: "Button2" strong: true }

Minus is that language is not supported by my Intellij, but there are plugins for Eclipse and NetBeans.

But what totally disapointed me was that it is looks very raw and not ready for production use. For example, there is no textarea (TEXTAREA!!!),  there are only basic layouts like grid and horizontal/vertical boxes. In Java 6 there is already GroupLayout, it even looks the same way as JavaFX, but still for some reason it is not part of it. There is general feeling that it is more like some fancy toy, but not usefull tool to do things. What kind of form can one build with grid layout?

There is one interesting concept though. Which maybe even future of layout managers - it is called binding. I have not seen anything like it before and to me it seems really interesting. It is possible to bind one parameter to some variable or variable expression, and when this bound variable changes, initial parameter is updated. So for example, you can bind start of textfields to maximum value of labels and this way to have nicely aligned form.

Anyway, even if there are some cool and promising features, I needed textarea and some normal layout for forms, so I decided to stick with Swing just for a while more.

Maybe I'll have more luck with Griffon.

There was article on JavaLobby with link to another article about upcomming features in JavaFX 1.3. And it already looks a little bit better with Textarea and CSS. So I'll wait for next version.

Full article at

No comments:

Post a Comment