JavaFX: Common classes

The default program created by Netbeans has event and we will cover event in our later posts.

Using our 3 sequence of procedures, let’s create another more straight forward example to illustrate some common JavaFX classes.

In the example program below, we have 7 import statements which mean that we are using 7 JavaFX classes to display a Hello World text in our program.

In this example, we have used Stage and Scene classes similar to the previous example.

What are new here are actually the Text, Font and Color classes.

I will explain how I have used the 3 classes to display the text in the scene in the next post.

package javafxapplication4;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;

public class JavaFXApplication4 extends Application {

    public void start(Stage primaryStage) {

        primaryStage.setTitle("JavaFX Program!");

        StackPane stackpane = new StackPane();

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

        Text txt = new Text();
        txt.setFont(Font.font("Times New Roman", 36));
        txt.setText("Hello World");


    public static void main(String[] args) {



Series Navigation<< JavaFX: How The Button Is Created
JavaFX: Setting the text for display >>