Skip to content

Instantly share code, notes, and snippets.

@mikehearn
Last active September 30, 2017 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikehearn/bccd66cde507d12ea85e6a4842d75008 to your computer and use it in GitHub Desktop.
Save mikehearn/bccd66cde507d12ea85e6a4842d75008 to your computer and use it in GitHub Desktop.
Hello World in JavaFX using Nashorn
// Run like this: jjs -fx hello.js
load("fx:base.js");
load("fx:controls.js");
load("fx:graphics.js");
// Set the title bar.
$STAGE.title = "Hello World!";
// Create a button and place it in a layout that will center it.
var button = new Button();
button.text = "Say 'Hello World'";
button.onAction = function() print("Hello World!");
var root = new StackPane();
root.children.add(button);
// Make a small window to contain it all and show.
$STAGE.scene = new Scene(root, 300, 250);
$STAGE.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment