如何将新项目添加到在jtextfield中键入的jtextarea? [英] How do I add new item to jtextarea that was typed in jtextfield ?
本文介绍了如何将新项目添加到在jtextfield中键入的jtextarea?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码你怎么认为有问题?
this is my code how do you think is there a problem?
private class Listener implements ActionListener {
public void actionPerformed(ActionEvent e) {
list.add(text1.getText());
string += list.get(list.size() - 1) + "\n";
area.setText(string);
text1.setText("");
}
}
我的尝试:
我试图使用一些内置函数
What I have tried:
I have tried to use some built-in functions
推荐答案
我已经解决了谢谢你,这就是答案
guys i have solved it thank you and here is the answer
private class Listener implements ActionListener {
public void actionPerformed(ActionEvent e) {
list.add(text1.getText());
String string = "";
for (int i = 0; i < list.size(); i++) {
string += list.get(i) + "\n";
}
area.setText(string);
text1.setText("");
}
}
这篇关于如何将新项目添加到在jtextfield中键入的jtextarea?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文