英文:
TextArea with string on top of another string
问题
textArea有一个显示字符串值的textArea。我有一个带有eventHandler的按钮。当我按下这个按钮时,我想要添加另一个字符串和新值(将其添加到前一个值)。我正在使用
textArea.appendText(" string" + cost);
但是这会将其添加到textArea中前一行的旁边,但我希望这一行位于其下方。我一直没有找到可以替代append的方法。是否有一种在下方添加新行的方法?
英文:
I Have a textArea that displays a string with a value. I have a button with an eventHandler attached. When I press this button, I want to add another string and new value (which adds to the prev value). I am using
textArea.appendText( " string" + cost);
But this is adding it next to the previous line in the textArea, but I want this line to be below it. I
have not been able to find a method to use instead of append. Is there a way to add the new line below?
答案1
得分: 0
Use "\n" 用于换行,在每个需要换行的字符串之间添加。
英文:
Use "\n" for new line, one each string that you want to be on a new line
答案2
得分: 0
Append your text with an Escape Sequence("\n").
This should put the new line below it.
You can do something like this:
textArea.appendText("\n" + cost);
英文:
Append your text with an Escape Sequence("\n").
This should put the new line below it.
You can do something like this:
textArea.appendText("\n" + cost);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论