JavaFx preview released, here’s my HelloWorld app and some initial thoughts

Sun Microsystems today announced a preview release of the JavaFX SDK.

I’ve been observing this new entrant into the RIA space from the outside but today I thought it was time to dig in a little bit. So I got my hands on the latest Netbeans wit JavaFx support and cooked up this little Hello World application.
 

Initial thoughts

Here are my initial thoughts of the technology .. I will try and share more detailed opinion, once I know the technology a little better ..

  • I don’t particularly like the YAML like declarative syntax for describing UI .. I think XML as used by Flex and Silverlight is more readable .. but I guess this is more of a personal preference
  • The Netbeans IDE for JavaFx is fairly basic and somewhat buggy right now, I hope this will improve over time
  • Did they really achieve their goal of making Java UI development simpler than Swing? .. I’m not so sure … I guess I’m still getting used to the JavaFx style of UI development
  • JavaFx needs a good way to share source, Flex’s really easy way of sharing code has helped adoption, since it makes is very easy for the people in the community to share and learn from each other

 
Launch Application using Java Web Start
(Note, Java 1.6 is required)
 

Source:
/*
 * Main.fx
 *
 * Created on Aug 1, 2008, 6:00:51 AM
 */

package helloworld;

import javafx.application.Frame;
import javafx.application.Stage;
import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.text.Text;
import javafx.scene.Font;
import javafx.scene.FontStyle;
import javafx.scene.paint.Color;

/**
 * @author Mrinal Wadhwa
 */
public class HelloNode extends CustomNode {

    public function create(): Node {
        return Group {
            content: [
                Text {
                    font: Font {
                        name: "Verdana"
                        size: 30
                        style: FontStyle.PLAIN
                    }
                    x: 60, y: 110
                    fill: Color.WHITE
                    stroke: Color.WHITE
                    content: "Hello World from JavaFx"
                }]
        };
    }
}

Frame {
    title: "Hello World !"
    width: 500
    height: 250
    closeAction: function() {
        java.lang.System.exit( 0 );
    }
    visible: true

    stage: Stage {
        fill: Color.DARKGRAY
        content: HelloNode{}
    }
}

I will share more detailed code whenever I get some more time to play with JavaFx. Meanwhile here are a few resources that will help you learn ..

I look forward to the final release of Java SE Update 10 and the final release of JavaFx SDK .. these are exciting times in RIA land.


About this entry