如何从一个ArrayList包含textArea的setText? [英] How to setText in a textArea from an ArrayList?
问题描述
我有一个ArrayList 的ArrayList<串GT; externalDataList =新的ArrayList<>(1600);
,我想在textarea的第一个3串来显示,但我不能赢得成功:
I have an ArrayList ArrayList<String> externalDataList = new ArrayList<>(1600);
and I would like to display in a textArea first 3 strings, but I can't succed:
下面是我的code
textareaShowPreview.setPrefRowCount(3);
Iterator<String> it = externalDataList.iterator();
int tot = 0;
while(it.hasNext() && tot<3){
String element = it.next();
textareaShowPreview.setText(element + "\n");
System.out.println("elements are: " + element);
tot++;
}
sout将正确打印第3串
The sout correctly print first 3 strings
element are: 23/05/2007 ,30.9455,31.2545,30.9091,30.9545,7518142
element are: 24/05/2007 ,30.6545,31.0909,30.5364,30.6909,12851606
element are: 25/05/2007 ,30.6636,30.8545,30.4818,30.8091,9392088
但在textarea的我只有第一个
but in textArea I have only first one
我如何要修改我的code在TEXTAREA显示所有三根弦,每行一个字符串?
How do I have to modify my code to show in textArea all three strings, one string per row?
推荐答案
使用AppendText通过替代的setText <一个href=\"http://docs.oracle.com/javafx/2/api/javafx/scene/control/TextInputControl.html#appendText%28java.lang.String%29\"相对=nofollow>这里是一个链接。
Use appendText instead of setText here is a link.
本的setText,删除previous文本,并设置你给它的文本。追加保持在你的文本区的当前文本。
The setText, delete the previous text and set the text you are giving to it. The append keep the current text in your text area.
希望它帮助!
这篇关于如何从一个ArrayList包含textArea的setText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!