我想在基於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