Using JavaFX

79 views
Skip to first unread message

Chris Root

unread,
Apr 5, 2015, 6:02:41 PM4/5/15
to node...@googlegroups.com
I don't know that this is even possible. I gave it a try but not being a java programmer I probably missed something. I tried to do an example that can be found at

Trying to do the button import got me an error 

Error: Could not create class javafx.scene.control.Button
java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalStateException: Toolkit not initialized

var java = require('java');
java.classpath.push("commons-lang3-3.1.jar");
java.classpath.push("commons-io.jar");

var app = java.import("javafx.application.Application");
var evt = java.import('javafx.event.ActionEvent');
var ehandler = java.import('javafx.event.EventHandler');
var scene = java.import('javafx.scene.Scene');
//var button = java.import('javafx.scene.control.Button'); // caused error
var stackPane = java.import('javafx.scene.layout.StackPane');
var stage = java.import('javafx.stage.Stage');

So I tried doing the button in the start method

app.start = function(primaryStage){
var button = java.import('javafx.scene.control.Button');
var btn = new button();
btn.setText('Hello World');
//btn.setOnAction(new ehandler(evt));

var root = new stackPane();
root.getChildren().add(btn);

var scene = new scene(root,300,290);
primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
}

app.launch(null);

I wasn't sure how to so the event handler. executing this did absolutely nothing.

This might be totally utterly wrong and if so just be gentle with me. I would love to be able to do javafx apps in node but for all I know it might be impossible currently. Hoping someone can help.
Reply all
Reply to author
Forward
0 new messages