Welcome!

Linux Authors: Katharine Hadow, Hovhannes Avoyan, Anatoly Krivitsky, Pat Romanski, Suresh Krishna Madhuvarsu

Related Topics: Java

Java: Article

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.

More Stories By 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.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.