As I've mentioned before, compiled JavaFX Script is currently under development, and one of the last pieces of the puzzle is the UI features. Currently there are a few UI features that are operational in the compiled version, for example Frame, BorderPanel and Button. Fortunately, the user interface API (widgets and 2D graphics) is almost identical to interpreted JavaFX Script, as is the declarative scripting. For example, this classic border layout (BorderPanel widget) example executes in the interpreted, and compiled versions of JavaFX Script. Here's the BorderPanelMini.fx code listing followed by a screenshot:
/*
* BorderPanelMini.fx - A JavaFX program for use in a presentation
*
* Developed 2007 by James L. Weaver (jim.weaver at lat-inc dot com)
* to serve as a JavaFX Script example.
*/
import javafx.ui.*;
import java.lang.System;
import javax.swing.UIManager;
import sun.swing.plaf.nimbus.NimbusLookAndFeel;
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Frame {
title: "BorderPanel Mini-Example"
height: 300
width: 480
visible: true
content:
BorderPanel {
top:
Button {
text: "top"
}
center:
Button {
text: "center"
}
left:
Button {
text: "left"
}
right:
Button {
text: "right"
}
bottom:
Button {
text: "bottom"
}
}
}
Here a screenshot of the application:
The Brand-New Nimbus Look & Feel
In the I Hear Voices post I mentioned the Consumer JRE project, which is now called Java SE 6 Update N. According to this article by Chet Haase, this initiative has six main items that primarily address deployment and performance issues:
- Quickstarter. Radically reduce the startup time for Java applications and applets.
- Java Kernel. Reduce the time to install and launch when the user needs to install the JRE in order to run an application.
- Deployment toolkit. Enable easy detection and installation of the JRE.
- Installer improvements. Improve the user experience of installation.
- Graphics performance on Microsoft Windows. Enable default graphics acceleration for simple and advanced 2D rendering.
- Nimbus look and feel. Release a new cross-platform look and feel based on Synth.
I believe that this initiative will help enable the success of JavaFX. The last item mentioned is the Nimbus Look and Feel, which I think is very attractive. The screenshot above give a taste of the Nimbus Look and Feel, and the code example shows how to implement it in JavaFX Script programs. You'll need to download the latest Java SE 6 Update N early access release in order to use the Nimbus Look and Feel.
Enjoy,
Jim Weaver
JavaFX Script: Dynamic Java Scripting for Rich Internet/Client-side Applications
eBook (PDF) download available at the book's Apress site
Recent Comments