首页 > 解决方案 > JavaFX| .setWrapText() 不在 TextArea 中换行

问题描述

我有一个 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);

我怎样才能解决这个问题?

标签: javafxtextarea

解决方案


推荐阅读