Playing with the JavaFX SDK as it's Being Built
Join the DZone community and get the full member experience.Join For Free
as i mentioned in the jfx and the way forward after javaone 2008 post, sun announced at javaone that a preview release of the javafx sdk is scheduled to be available in july 2008. as a pleasant surprise over memorial day weekend, sun opened up the development of this preview release sdk. this development activity is occurring as a part of the openjfx compiler project, so follow the instructions that i gave you in the obtaining the openjfx script compiler just got easier post and join the fun! you'll be playing with the javafx sdk as it is being built, so expect changes. it would also be great if you'd provide input to the process, and help test the sdk as it's being developed.
write your first javafx program that uses the new javafx.gui classes
take a look at the javafx script api documentation and you'll notice that there are two sets of ui-related packages. the javafx.ui packages contains the older, prototype ui classes, and the javafx.gui packages contain the ui classes that will be in the javafx sdk. the javafx code below uses these newer ui classes, and i'll show you how to compile and run this code in a bit. when the application first starts up, an empty window appears with two buttons:
when you click the hello button, the message "you say hello..." from the popular "hello, goodbye" beatles song displays approximately in the center of the window:
when you click the goodbye button, the message "and i say goodbye" appears in place of the former message:
here's the javafx code that generated this user interface and functionality:
* hellogoodbye.fx -
* a "hello world" style program that demonstrates
* declaratively expressing a user interface.
title: "hello, goodbye"
content: bind phrase
// the button was clicked
phrase = "you say hello...";
phrase = "and i say goodbye";
compiling and running the program
to compile this program, enter the following into the command line:
javafxc -d . hellogoodbye.fx
as in java, the -d option causes the class files to be put into a directory corresponding to the package statement subordinate to the specified directory. to run the program, use the following command:
now that you've got access to the javafx sdk as it's being built, get involved by writing javafx programs that exercise its functionality, and subscribe to one or more of the following mailing lists from this page .
javafxpert bootcamp in oslo, norway, on june 18-20, 2008
if you happen to be in the vicinity of oslo, norway later this month, please come to the free javafx script seminar sponsored by bouvet on june 18, 2008. i'll be teaching the seminar, followed by a two day javafxpert bootcamp . contact bouvet for information on registering for the bootcamp.
have fun, and please post a comment if you have any questions!
javafx script: dynamic java scripting for rich internet/client-side applications
immediate ebook (pdf) download available at the book's apress site
Opinions expressed by DZone contributors are their own.