Top Linux Links You Must Click On


Playing with UI Features in Compiled JavaFX Script
Introducing the Brand-New Nimbus Look & Feel

From Jim Weaver's Learn JavaFX Weblog

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:

Borderpanelmini


The Brand-New Nimbus Look & Feel

In my I Hear Voices blog 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 gives 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.

About James L. Weaver
James L. (Jim) Weaver is founder and president of jMentor, formed in 2000 to provide Java programming-related training to companies and individuals. He has served as a system architect and developer for over 25 years, specializing in leading-edge software development. His specialties include Java, object-oriented, and web-based technologies. He has authored books on the Java programming language, including most recently JavaFX Script, published by Apress.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

  Subscribe to our RSS feeds now and receive the next article instantly!
In It? Reprint It! Contact advertising(at)sys-con.com to order your reprints!
ADS BY GOOGLE
Subscribe to the World's Most Powerful Newsletters