Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将文本附加到Java程序中的文本区域?_Java_Swing_User Interface_Awt_Append - Fatal编程技术网

如何将文本附加到Java程序中的文本区域?

如何将文本附加到Java程序中的文本区域?,java,swing,user-interface,awt,append,Java,Swing,User Interface,Awt,Append,我有一个名为text_ref的文本区域。我需要将文本附加到它,而不是重写它。类似于日志,文本被附加到日志中,并且从不被覆盖。如何向其添加文本?我目前正在使用“setText” 使用append方法 text_ref.append(nationality + "is the nationality..."); 使用append方法传递需要追加的字符串文本 text_ref.setText(nationality + "is the nationality..."); text_ref.a

我有一个名为text_ref的文本区域。我需要将文本附加到它,而不是重写它。类似于日志,文本被附加到日志中,并且从不被覆盖。如何向其添加文本?我目前正在使用“setText”


使用
append
方法

text_ref.append(nationality + "is the nationality...");

使用
append
方法传递需要追加的字符串文本

  text_ref.setText(nationality + "is the nationality...");
  text_ref.append("I am just appending here to the current text");

要在JTextArea子对象中追加文本,必须使用此对象的append方法

text_ref.append("some text to append");


有可用的append()方法。-1只要看一下文档就可以给出答案。我可以理解,有时很难找到您要查找的内容,如果该方法的名称很神秘,但是人,
append()
是列表中的第一个方法。
text_ref.append("some text to append");
nationality = "Polish";
text_ref.append(nationality);