ArrayList list_of_employees = new ArrayList();
@Action
public void reportAllEmployeesClicked(java.awt.event.ActionEvent evt)
{
this.outputText.setText("");
int i=0;
//JOptionPane.showMessageDialog(null,"test Employee list print");
ListIterator list_ir = list_of_employees.listIterator(); //list_of_employees is of
//obj type ArrayList
while(list_ir.hasNext())
{
String o = new String();
o = (String) list_ir.next();
this.outputText.setText(""+o); // this does not work, why? nothing happens
//no errors and no output
i++;
JOptionPane.showMessageDialog(null,o); // this works
}
}
outputText 是嵌套在滚动窗格内的 JTextArea 类型。当我使用普通字符串变量设置文本时,输出会按原样显示。当循环运行时,我能够通过 JOptionPane 获得输出。存储在列表中的所有对象都是 String 对象。如果我需要提供更多信息以促进更准确的答案,请告诉我。
谢谢-威尔-