1  import javafx.application.Application;
  2  import javafx.scene.Scene;
  3  import javafx.scene.layout.Pane;
  4  import javafx.scene.paint.Color;
  5  import javafx.geometry.Insets;
  6  import javafx.stage.Stage;
  7  import javafx.scene.text.Text;
  8  import javafx.scene.text.Font;
  9  import javafx.scene.text.FontWeight;
 10  import javafx.scene.text.FontPosture;
 11  
 12  public class ShowText extends Application {
 13    @Override // Override the start method in the Application class
 14    public void start(Stage primaryStage) {
 15      // Create a pane to hold the texts
 16      Pane pane = new Pane();
 17      pane.setPadding(new Insets(5, 5, 5, 5));
 18      Text text1 = new Text(20, 20, "Programming is fun");
 19      text1.setFont(Font.font("Courier", FontWeight.BOLD, 
 20        FontPosture.ITALIC, 15));
 21      pane.getChildren().add(text1);     
 22  
 23      Text text2 = new Text(60, 60, "Programming is fun\nDisplay text");
 24      pane.getChildren().add(text2);     
 25  
 26      Text text3 = new Text(10, 100, "Programming is fun\nDisplay text");
 27      text3.setFill(Color.RED);
 28      text3.setUnderline(true); // Underline for text3
 29      text3.setStrikethrough(true); // Strikethrough for text3
 30      pane.getChildren().add(text3); 
 31      
 32      // Create a scene and place it in the stage
 33      Scene scene = new Scene(pane);
 34      primaryStage.setTitle("ShowText"); // Set the stage title
 35      primaryStage.setScene(scene); // Place the scene in the stage
 36      primaryStage.show(); // Display the stage
 37    }
 38    
 39    /**
 40     * The main method is only needed for the IDE with limited
 41     * JavaFX support. Not needed for running from the command line.
 42     */
 43    public static void main(String[] args) {
 44      launch(args);
 45    }
 46  }