Hello JavaFX 2! - Back To Java 📎
package com.abien.hello;
import javafx.application.Application;
import javafx.application.Launcher;
import javafx.collections.Sequence;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class Main extends Application{
@Override public void start() {
Stage stage = new Stage();
stage.setTitle("Hello Java FX");
stage.setResizable(false);
Group root = new Group();
Scene scene = new Scene(root,80,20);
stage.setScene(scene);
Sequence children = root.getChildren();
children.add(new Label("Hello Java FX 2"));
stage.setVisible(true);
}
public static void main(String[] args) {
Launcher.launch(Main.class, args);
}
}
Java FX 2 application can be compiled having jfxrt.jar in the classpath and launched like any other Java application: java -cp javafx-sdk2.0-ea/rt/jfxrt.jar com.abien.hello.Main
Even in the case of the preview the startup performance is <1 sec and significantly faster, than 1.X version.
This post is based on Java FX 2 Early Access - the API and runtime can change any time.
Sees official JavaFX roadmap for more details.