Create a simple JavaFx program with an empty scene

This article will be a warm-up for a new JavaFx game project tutorial, which I will create and share on this blog. What we will create in this article is a simple blank game scene using the JavaFx library. If you already have the Java 8 SDK installed on your computer, you will also install the JavaFx library.

The following ui program is a simple program uses to display the blank scene of JavaFx.

package info.codingdirectional;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class JavaFxExample extends Application {
	
	private double CANVAS_WIDTH = 300;
	private double CANVAS_HEIGHT = 300;

	@Override
	public void start(Stage stage) throws Exception {
		StackPane root = new StackPane();
		Scene theScene = new Scene( root, CANVAS_WIDTH, CANVAS_HEIGHT);
		stage.setScene(theScene);
		stage.setTitle( "Empty Game Scene" );
		stage.show();
	}
	
	public static void main(String[] args) {
		Application.launch(args);
	}

}

The width and height of the scene are both 300.

Empty Scene
Empty Scene