package simpletest2; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.TextArea; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class TextAreaTest extends Application { @Override public void start(final Stage stage) { final String text = "This is a fairly long string that won't fit in the textbox; \n" + "you can scroll to the end to see the last part of the sentence.\n" + "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 \n" + "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 \n" + "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 \n" + "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 \n" + "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 \n" + "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 \n" + "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 \n" + "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 \n" ; System.out.println("text length: " + text.length()); final StackPane p = new StackPane(); final TextArea textBox = new TextArea(text); p.getChildren().add(textBox); stage.setScene(new Scene(p)); stage.setWidth(400); stage.show(); } public static void main(final String[] args) { Application.launch(TextAreaTest.class, args); } }