Hello World - JavaFX Tutorial Part 2

This is a tutorial on coding a basic "hello world" JavaFX application. We'll take a look at scenes, nodes and the stage and create a simple window to get started with JavaFX.

We're going to move on in the next tutorials to look at Scene Builder, actions and stylesheets. At the moment I'm not sure what direction future tutorials will take, but we'll certainly build a little demo application of some sort, and it might be interesting to investigate 3D graphics, who knows ...




App.java:

 
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;


public class App extends Application {

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

    @Override
    public void start(Stage primaryStage) throws Exception {
        
        Group root = new Group();
        Scene scene = new Scene(root, 600, 400);
        
        primaryStage.setScene(scene);
        primaryStage.setTitle("Hello World!");
        primaryStage.show();
    }

}

 

Download complete code here.