【问题标题】:JavaFX how to write text to a new line in a textArea?JavaFX如何将文本写入textArea中的新行?
【发布时间】:2015-04-08 11:31:18
【问题描述】:

我用这个: TextA.appendText(String)有没有办法把文字放到下一行?

【问题讨论】:

  • 你的意思是不是使用appendText?
  • textArea.appendText(string + "\n");

标签: java string javafx append


【解决方案1】:
String newLine = System.getProperty("line.separator");

或者如果你想更直接一点:

String newLine = "\n";

将新行追加或添加到您的 TextArea 以创建新行。

【讨论】:

  • 我在 Windows 上,如果你想要准确的话,我会尝试使用 \r\nSystem.lineSeperator() 进行拆分。这没有奏效,因为 TextArea 似乎忽略了操作系统并且一直使用\n。我没有在 JavaDoc 中看到对此的确认,所以我想问一下 TextArea 是否确实忽略了操作系统
【解决方案2】:

TextA.appendText("\n")

将添加一个新行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-09
    • 2020-10-12
    • 1970-01-01
    • 1970-01-01
    • 2020-08-23
    • 2020-08-26
    • 2018-03-19
    • 2019-03-15
    相关资源
    最近更新 更多