Javafx 2 如何在TextArea中的多行上显示文本
我测试了这段代码以在几行上显示字符串:Javafx 2 如何在TextArea中的多行上显示文本,javafx-2,javafx,javafx-8,Javafx 2,Javafx,Javafx 8,我测试了这段代码以在几行上显示字符串: TextArea dataPane = new TextArea(); dataPane.setEditable(false); dataPane.prefWidthProperty().bind(hbox.widthProperty()); dataPane.setWrapText(true); // New line of the text exceeds the text area
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");
但结果我只得到了字符串数据
。在JavaFX中,在几行上显示字符串的正确方式是什么
setText(“Testdata\nda”)。您刚刚覆盖了现有文本。请看一下,这是相同的问题。
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");