我想在基于for和if循环的ArrayList中设置JCombobox中的值。JComboBox没有显示结果
//salesman=the name of the combobox
salesman = new javax.swing.JComboBox();
DefaultComboBoxModel model = new DefaultComboBoxModel();
salesman.setModel(model);
/*company is an object of Company class, that gets set with a setter method to ensure
that the gui will be pointing to the right object. and it does contains the data i want, so
i am sure that company is not the problem */
//loop tp set box list
for (Employee current : company.getArray()){
if (current instanceof Salesman) {
salesman.addItem(current.getCode());
}
}
但是组合框保持空白。这是为什么 ?
实际上,它可能不是空的(但相当小,如果* Salesman.getCode()。toString()*返回空:)) – 2010-12-19 13:03:23