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
14 public void start(Stage primaryStage) {
15
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);
29 text3.setStrikethrough(true);
30 pane.getChildren().add(text3);
31
32
33 Scene scene = new Scene(pane);
34 primaryStage.setTitle("ShowText");
35 primaryStage.setScene(scene);
36 primaryStage.show();
37 }
38
39
43 public static void main(String[] args) {
44 launch(args);
45 }
46 }