[英]How to print the console output to the JTextArea?
以下是我的Java代碼:
有人可以建議如何在JTextArea
上打印嗎?
DBCursor cursor = coll.find();
int i=1;
while (cursor.hasNext())
{
System.out.println("Inserted Document: "+i);
System.out.println(cursor.next()); // i want to print this into jtextarea
i++;
}
您可以將輸出添加到textarea,如下所示:
textarea.append(""+cursor.next());
您可以只使用JTextArea.setText(String)
和JTextArea.append(String)
來做到這一點。
setText
替換文本區域中的文本。 append
將string
添加到現有文本的末尾。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.