JavaFX Application To Create Stage And Scene

This is a simple program to create a JavaFX Application which displays Hello World !
Screenshots:



The Code:
package javafxapplication1;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 *
 * @author Matrix
 */
public class JavaFXApplication1 extends Application {
 
    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {
         
            @Override
            public void handle(ActionEvent 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);
    }
 
}

Found Bugs, Please report us !

Comments

Popular posts from this blog

Non Restoring Division Algorithm Implementation in C

Hackerrank Modified Kaprekar Numbers Solution

Bit Stuffing Code Implementation in Java