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