/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rhinotest;

import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 *
 * @author Administrator
 */
public class RhinoTest extends Application {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		launch(args);
	}
	private static Button btn;
	private static StackPane root;
	
	@Override
	public void start(Stage primaryStage) {
		primaryStage.setTitle("Hello World!");

        ScriptEngineManager engineMgr = new ScriptEngineManager();
       	final ScriptEngine engine = engineMgr.getEngineByName("ECMAScript");

		btn = new Button();
		btn.setText("Say 'Hello World'");
		btn.setOnAction(new EventHandler<ActionEvent>() {

			@Override
			public void handle(ActionEvent event) {
			}
		});
		
		root = new StackPane();
		root.getChildren().add(btn);
		primaryStage.setScene(new Scene(root, 300, 250));
		primaryStage.show();

				try {
					System.out.println("Hello World!");
					engine.eval("Packages.rhinotest.TestNode.test();");
				} catch (ScriptException ex) {
					ex.printStackTrace();
				}
	}

	public static void showNode(Node node) {
		root.getChildren().clear();
		root.getChildren().add(node);
	}
}
