Aug 13

JavaFX Demo Code

Posted: under JavaFX, Others.
Tags: , August 13th, 2008

Got a JavaFX Demo Code from Josh Marinacci, a key JavaFX team member. From this demo, we can see the source code is very succinct. I did some Java Swing programming before, so I understand this means the tremendous effort savings in user interface implementation.

import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.geometry.*;
import javafx.application.*;
import javafx.scene.transform.*;
import javafx.input.*;
import javafx.animation.*;
import java.lang.System;

var angle = 0.0;

Frame {
    windowStyle: WindowStyle.TRANSPARENT  visible: true
    width: 400 height: 400
    stage: Stage {
        fill: null
        content: Group {
            translateX: 100 translateY: 100
            content: for(i in [0..10]) {
              // here is the magic with binding
              Rectangle {
                fill: Color.rgb(25*i,0,0, i/10.0)
                width: 100
                height: 100
                arcHeight: 10 arcWidth: 10
                stroke: Color.BLACK strokeWidth: 5
                transform: bind [
                  Transform.rotate(-i*36+angle/2,50,50),
                  Transform.translate(angle/4,0),
                 ]
               }
            }
          onMousePressed:
           function(e:MouseEvent):Void
           { System.exit(0); }
        }
    }
}

var anim = Timeline { keyFrames: [
   KeyFrame { time: 0s
    values: angle => -360 tween Interpolator.EASEBOTH },
   KeyFrame { time: 2s
    values: angle => 360 tween Interpolator.EASEBOTH },
    ]
   autoReverse: true
   repeatCount: Timeline.INDEFINITE
};
anim.start();

Though I do not fully understand the code, it seems to me it is a simple way to things we used to spend tons of work. Currently, the CPU usage is a bit higer, so I think they can improve it when the final release comes out.

Comments (0)

Aug 01

JavaFX Preview SDK

Posted: under JavaFX.
Tags: , , , , August 1st, 2008

Yesterday, the JavaFX Preview SDK is available for download. This is very exciting news. Since its debute on JavaOne 2007, many enthusiasts cheered of this preview release. The formal release is schedule to be out on Dec 2, 2008. We can’t wait to get it.

Though JavaFX is a technology based on Java, it totally changes the world of “Your Dad’s Java”. Many GUI related things can be done easily on JavaFX, such as graphic, video, audio, and anything for RIA. People are excited because JavaFX provides a very simple way to implement these elements in an RIA’s GUI.

JavaFX also links the world between art designer and computer programmer. Traditionally, these two kinds of folks find them hard to work with each other. With the birth of JavaFX, we finally have an approach to combine two things easily.

With a few lines of code, JavaFX can render sophiscated GUIs that used to be done by Java with 10 times of source code. JavaFX has many build-in features of doing animation, graphical effects that are seen photoshop.

I will download and test drive the preview SDK soon.

Comments (0)