我正在将文本输出到 Java FX 中的文本区域,但如何防止用户使用滚动条导航到文本末尾并阻止文本溢出? (请参见下图)
下面是我的 GUI.fxml 类中的代码
<Tab closable="false" text="Second Link">
<content>
<SplitPane dividerPositions="0.5" prefHeight="160.0" prefWidth="200.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TextArea fx:id="secondText" layoutX="22.0" layoutY="48.0" prefHeight="511.0" prefWidth="571.0" />
<TextField layoutX="215.0" layoutY="14.0" text=" Original Text" />
</children></AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="363.0" prefWidth="292.0">
<children>
<TextField layoutX="215.0" layoutY="14.0" text=" Summary" />
<TextArea layoutX="16.0" layoutY="48.0" prefHeight="511.0" prefWidth="571.0" />
</children>
</AnchorPane>
</items>
</SplitPane>
</content>
</Tab>
任何帮助将不胜感激,提前致谢。
最佳答案
将 wrapText=true
添加到 TextArea
元素。它将把文本换行到新行而不是滚动。
关于java - 如何阻止 Javafx 上的文本溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43778830/