package simpletest2; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.layout.FlowPane; 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 FlowPane p = new FlowPane(); final TextArea textArea = new TextArea(text); p.getChildren().add(textArea); p.getChildren().add(new TextField("some text")); stage.setScene(new Scene(p)); stage.setWidth(400); stage.show(); } public static void main(final String[] args) { Application.launch(TextAreaTest.class, args); } }