Interactive JavaFX Script shell

One thing I don’t like about JavaFX (compared to HTML) is the edit, recompile, launch, debug cycle. In HTML, it is a matter of editing the file and refreshing with F5.

Imagine my delight when I found the JavaFX SDK ships with an interactive shell.

C:javafx-sdk1.2>java -Djava.ext.dirs=lib/desktop;lib/shared/ com.sun.tools.javafx.script.
ScriptShell
/*fx1*/ def circle = javafx.scene.shape.Circle {centerX: 50 centerY: 50 radius:80 fill:javafx.scene.paint.Color.PURPLE }
le
/*fx2*/ def stage = javafx.stage.Stage { title: "Interactive stage" width: 400 height: 300 }
fx.stage.Stage@c7057c
/*fx3*/ import javafx.scene.Scene;
/*fx4*/ stage.scene = Scene {content: circle};
fx.scene.Scene@19e733e

Why do this?

Firstly, if you make any syntax errors, they get caught straight away. So explore away, saving the working snippets into your final source file.

Secondly, results are immediate. There is no need to restart the javafx application. Time is money.


About this entry