Introduction to JavaFX Programming with Java Language Graphical Interface

 1 minute to read
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
  * @author hack's home
  */
public class HelloJavaFX extends Application {

     @Override
     public void start(Stage primaryStage) throws Exception {
         Button btn = new Button();
         btn.setText("Hello, world");
         btn.setOnAction(event -> System.out.println("Hello, world!"));

         StackPane root = new StackPane();
         root.getChildren().add(btn);

         Scene scene = new Scene(root, 300, 250);

         primaryStage.setTitle("Hello World!");
         primaryStage.setScene(scene);
         primaryStage.show();
     }


     public static void main(String[] args) {
         launch(args);
     }
}