如何在TextArea中的多行显示文本 [英] How to display text on several lines in TextArea
本文介绍了如何在TextArea中的多行显示文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我测试了这段代码,以便在几行显示字符串:
I tested this code to display strings on several lines:
TextArea dataPane = new TextArea();
dataPane.setEditable(false);
dataPane.prefWidthProperty().bind(hbox.widthProperty());
dataPane.setWrapText(true); // New line of the text exceeds the text area
dataPane.setPrefRowCount(10);
dataPane.setText("Testdata");
dataPane.setText("\ndata");
但结果我只得到String 数据
。在JavaFX中在多行显示字符串的正确方法是什么?
But as a result I get only the String data
. What is the proper way to display strings on several lines in JavaFX?
推荐答案
TextArea dataPane = new TextArea();
dataPane.setEditable(false);
dataPane.prefWidthProperty().bind(hbox.widthProperty());
dataPane.setWrapText(true); // New line of the text exceeds the text area
dataPane.setPrefRowCount(10);
dataPane.setText("Testdata");
dataPane.appendText("\ndata");
这篇关于如何在TextArea中的多行显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文