import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import java.awt.desktop.AboutEvent;
import java.awt.desktop.AboutHandler;
import java.awt.Desktop;
import javax.swing.SwingUtilities;

public class HelloWorld extends Application implements AboutHandler {

static {
java.awt.Toolkit.getDefaultToolkit(); // Start AppKit
Thread t = new Thread(() -> { java.awt.Toolkit.getDefaultToolkit(); });
       t.start();
}

@Override
public void init() {
     Thread t = new Thread(() -> {
Desktop desktop = Desktop.getDesktop();
desktop.setAboutHandler((AboutHandler)this);
});
t.start();
}

@Override
public void start(Stage primaryStage) {
// create a button with specified text
Button button = new Button("Say 'Hello World'");
// set a handler that is executed when the user activates the button
// e.g. by clicking it or pressing enter while it's focused
button.setOnAction(e -> {
//Open information dialog that says hello
String prop = System.getProperty("apple.awt.application.name","No such");
System.out.println("prop -> " + prop + " on main thread");
Alert alert = new Alert(AlertType.INFORMATION, prop);
alert.showAndWait();
});

// the root of the scene shown in the main window
StackPane root = new StackPane();
// add button as child of the root
root.getChildren().add(button);
// create a scene specifying the root and the size
Scene scene = new Scene(root, 500, 300);
// add scene to the stage
primaryStage.setScene(scene);
// make the stage visible
primaryStage.show();
    }
    
    public void handleAbout(AboutEvent evt) {
     System.out.println("got to handleAbout");
     Platform.runLater(() -> {
     Alert alert = new Alert(AlertType.INFORMATION, "About HelloWorld");
alert.showAndWait();
});
    }

public static void main(String[] args) {
// launch the HelloWorld application.
// Since this method is a member of the HelloWorld class the first
// parameter is not required
Application.launch(HelloWorld.class, args);
}
} 