2
我有这个组合框,我想要的是每当我改变选择,即对应于选择放置在文本字段中的数字。最初,文本字段是空白的,当我选择某个东西时,它显示得很好,但它不会根据我的选择而改变。ComboBox ActionListener Java
下面是操作方法:
private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt)
{
jTextField1.setText("");
Iterator<Product> it = warehouse.getStock().iterator();
if(!warehouse.getStock().isEmpty())
{
x: while(it.hasNext())
{
Product temp = it.next();
if(temp.getName().equals(jComboBox5.getSelectedItem()))
{
jTextField1.setText(Integer.toString(temp.getQuantity()));
break x;
}
}
}
}
如果需要的话我会添加额外的代码。我能做什么?
*为了更好地帮助越早,张贴[SSCCE](http://sscce.org/ )。 – 2012-04-18 10:02:56
这个方法从哪里调用? – 2012-04-18 10:04:16