Paragraphs are separated by '\n' and the text is wrapped on paragraph boundaries. : Text « JavaFX « Java






Paragraphs are separated by '\n' and the text is wrapped on paragraph boundaries.

  

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Main extends Application {

  @Override
  public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);
    stage.setTitle("Sample");

    Text t = new Text(10, 50, "This is a test");
    t.setText("First row\nSecond row");
    t.setFont(new Font(20));

    root.getChildren().add(t);


    stage.show();
  }

  public static void main(String[] args) {
    launch(args);
  }
}

   
    
  








Related examples in the same category

1.Create Static Text control and set color
2.Rotate a Text
3.Text with DropShadow
4.Text with CHOCOLATE color and Font.SERIF
5.Line breaking for Text
6.Reflection effect on text
7.Set fill and font for Text
8.Binding Stage x, y, width, height to Text control
9.Text wrapping width
10.Set Text Font
11.Text class defines a node that displays a text
12.Reflected Text
13.Text Effect show off