JavaFX Tutorial – We shall build a Basic JavaFX Example Application to understand the basic structure and start working with JavaFX Applications.

Basic JavaFX Example Application

Following is a step by step guide to build Basic JavaFX Example Application :

  1. Create a new JavaFX Project.

    Follow the clicks : Main Menu -> File -> New -> Project -> JavaFX -> JavaFX Project.
    Provide the ‘Project Name‘ – JavaFXExamples and click on Finish.
    JavaFXExamples project of type JavaFX would be created.

  2. Main Class

    By default, Main.java would be created in /src/application/ with necessary code to start the application with an empty window.

  3. Create a Text message.

    We shall replace BorderPane with StackPane and add a Text shape to the StackPane. The complete JavaFX Class program is given below :

  4. Run the Application.

    Follow the clicks Main Menu -> Run -> Run.

    Basic JavaFX Example Application - JavaFX Tutorial - www.tutorialkart.com

    Application Window

Conclusion :

In this JavaFX Tutorial – Basic JavaFX Example Application, we have learnt to create a JavaFX application, display a Text Shape, and run the application.