我有一个 TextArea 控件,我试图使文本换行,无论我是在其中键入还是加载文件内容,都会换行。我的
.setWrapText()
通话无法正常工作,我不确定原因。我的组件结构是 Tab>BorderPane>TextArea
,这就是我创建控件的方式:
Tab newTab = new Tab("New File ");
BorderPane borderPane = new BorderPane();
JFXTextArea mainText = new JFXTextArea();
mainText.prefWidthProperty().bind(borderPane.widthProperty()); //found this somewhere online earlier been on this the whole day and I cant seem to pinpoint the link exactly
mainText.setWrapText(true);
borderPane.setCenter(mainText);
newTab.setContent(borderPane);
我该如何解决这个问题?
我也有类似的问题。 我将文本从书中复制到 TextArea,但 setWrapText() 不起作用。 后来,我发现转义字符 /n 阻止了该方法的工作。 当我删除它们时,它工作正常(我认为在行中的 85 个字符上)。