In association with heise online

JavaFX Script

JavaFX Script, originally called F3, is a technical response to the complaint that Java is too structured and verbose a language for web developers used to dynamic languages like JavaScript, Python or Ruby. JavaFX Script, more often called just JavaFX, is a simpler, statically typed language, but because it compiles to Java .class files, not only runs in the Java Virtual Machine, but can also call on Java libraries and code, when needed. The idea is to give Java developers a user interface language that can be isolated from the business logic that they may already have created in Java, without creating complex Swing applications, which are aimed only at the traditional desktop. Instead, they can implement a JavaFX UI with the code in JavaFX Script. Although this can use Swing components, it is much more oriented to declaring user interfaces as Java 2D based "stages". To get a feel for what JavaFX Script looks like, here's the code of a graphical "Hi From Heise" JavaFX program.

    package hifromheise;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;

Stage {
title: "Hi"
scene: Scene {
content: Text {
font : Font {
size : 24
}
x: 10
y: 30
content: "Hi From Heise"
}
}
}

The "Hi from Heise" JavaFX program running
The "Hi from Heise" JavaFX program running
This code declares a Stage for an application. The Stage contains a Scene, which is a notional space for for UI elements to appear in, and the content of the Scene is a Text element with a setting for a font, its position on the stage and what text it contains. The important element is the Scene, which creates a space for those UI elements. The Stage is a 2D scene graph that manages many of the transitional and animation functions. These would normally have to be explicitly written by a developer.

Print Version | Permalink: http://h-online.com/-746502
  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit
 


  • July's Community Calendar





The H Open

The H Security

The H Developer

The H Internet Toolkit