My name is Josh Marinacci and I'm excited about JavaFX because I love GUIs. I love graphics, animation, video, audio, and anything else that creates a richer user experience. Ever since I wrote my first fractal on a black and white Timex Sinclair (taking 2 hours to render a single 20x40 1bit image), I've been a GUI guy. I'm addicted and there is no cure.
So why am I excited about JavaFX? Because it gives us the freedom to create beautiful and responsive interfaces like never before. This isn't to say you can't do it in plain Java. If you've been to any of the last 4 JavaOne's then you've seen great interfaces we've built. But these demos were a ton of work, and after we finished we knew there had to be a better way to build awesome interfaces. And now, with the first public release of the JavaFX SDK, we can. Vector graphics, shaped windows, and keyframe animation are super easy. We get the same user experience on all platforms, with the same APIs coming on mobile in the near future. And best of all, we don't have to give up our Java code. Any Java class or API can be used directly from JavaFX Script. This lets us leverage the huge ecosystem of existing Java libraries out there.
Of course, being a GUI guy, I can't finish this post without showing some pretty pictures. One thing I love about JavaFX is that it shrinks your code. Well, perhaps it doesn't actually shrink your code like a ray gun from some mid-50s scifi movie, but it does let you write less code. JavaFX Script is optimized for graphical user interfaces, so things which are common in GUIs are very easy to do and require little code. Things like drawing and animation. For example, below is a simple app which draws a bunch of shaded spinning squares outside of a window. It grows and shrinks every two seconds, then quits when you click on it (if you can catch it).

The code is 45 lines long, or about 30 if you don't count the imports and whitespace. This would have taken two to three times as many lines if written in Java. The core is a sequence of rectangles, each with a transform bound to the central angle variable. A timeline changes the angle over time, which automatically updates the squares and repaints the screen. Setting the Frame's style to TRANSPARENT turns off the background, creating a shaped window. It's a complex animation made easy. That's the value of having a programming language and runtime optimized for GUIs.
package blogdemo;
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();
Now try the app yourself with JavaWebStart. Note, Java 1.6 is required.
Over the next few months you're going to see more blogs from me and other JavaFX developers, showing off tricks and waxing philosophic about graphical interfaces. And don't just think it's all eye candy. We've got lots of nutritional value here too. This is just the beginning of a great new platform for rich applications.
Gentlemen (and ladies).. start your engines.
First Post!
Posted by joshua@marinacci.org on July 31, 2008 at 12:48 PM PDT #
hi Josh,
JavaFX is definitely cool and powerful and I'm learning it too. But one thing that I find is that designer might find it hard to use than competing solution which use XML to build the UI front end. JavaFX Script feels more programmatic than declarative which at least make it more appealing to existing java developers. There are things that might need improving especially in area of CPU consumption and memory usage where from the weather example exhibit greater than 30%CPU and 60mb memory usage running on core2duo, but still I am upbeat that JavaFX will improve with time.
Is the HTML web component going to release soon ? JavaFX.com does not seem to mention it.
kudo to JavaFX team for the excellent release.
Posted by GeekyCoder on July 31, 2008 at 02:10 PM PDT #
Hi GeekyCoder. We feel that JavaFX Script will be comfortable to people who are used to JavaScript and ActionScript. For pure designers we have developed plugins for Photoshop and Illustrator (Project Nile) which lets designers share resources with developers.
We are continuing to do optimizations so the CPU and memory usage will improve in the future.
We don't have a release date yet for the HTML component. Sorry.
Thanks for your kudos. Let us know if you build any cool demos. We'd love to feature them.
Posted by Josh Marinacci on July 31, 2008 at 02:48 PM PDT #
Hello Josh!
I'm also a JavaFX enthusiast.
This applications worked here but WindowStyle.TRANSPARENT doesn't appears to work in my Ubuntu 8.04 even when I turn off compiz. :( Is this expected? There's some workaround?
Posted by Silveira Neto on July 31, 2008 at 11:50 PM PDT #
Is JavaFX script more than just a scripting language?
I mean, is it set to replace plain Java?
Can I use it to program all types of java apps that I used to program with plain java before?
Posted by BoyBawang on August 04, 2008 at 12:23 AM PDT #
hah... i clicked the link, had the right javersion, message "unable to launch application"...
Posted by mov__ax on August 04, 2008 at 08:59 AM PDT #
Do you have any more details on what it said? What was the full stacktrace / error console? What operating system and version of the JVM are you using?
Posted by Josh Marinacci on August 04, 2008 at 09:02 AM PDT #
will my applets have to be a 10mb download for a 10kb bit of my code?
Posted by debb on August 05, 2008 at 07:23 AM PDT #
Right now, yes. Before the 1.0 release of JavaFX we will have a copy of the runtime at known location which all demos will link to. This means the jars will only be downloaded once and shared by all JavaFX applications.
Posted by Josh Marinacci on August 05, 2008 at 08:20 AM PDT #
Hi josh!
Is JavaFX script set to replace all kinds of Plain Java development? What are the things JavaFX can't do that plain java can?
Posted by BoyBawang on August 06, 2008 at 12:00 AM PDT #
JavaFX is really for Graphical User Interfaces. For things like working with threads, database and network code, or talking to devices you should use Java. For example, you would never write a JavaEE app in JavaFX. Java is great for that. In fact, some of the demos we showed at JavaOne were Java/JavaFX hybrids. We used JavaFX for the GUI and Java for the network processing parts.
Posted by Josh Marinacci on August 06, 2008 at 10:05 AM PDT #
thanx for the response josh
one last question.
I'm going to make a GUI using JavaFX script with simple database in it. Can pure JavaFx script handle the simple database part? Or do i have to program the DB class with plain java?
Posted by boybawang on August 06, 2008 at 11:44 AM PDT #
For the time being you should use Java for the database parts.
Posted by Josh Marinacci on August 06, 2008 at 11:51 AM PDT #