【发布时间】:2013-08-12 18:55:23
【问题描述】:
为了制作一个项目,我在 jform 中有一些 jComboboxes,您可以在其中选择一些选项,并且当您想要编辑某些内容时,对象的某些值 (toString) 会显示在另一个 jform 中的 jcombobox 中,并选择该值。但它不想在组合框中显示值。我想在组合框中显示名字+名字(toString)
try {
ak = pdb.seekPerson(v.getBuyerId());
coKoper.removeAllItems();
} catch (ApplicationException ae) {
javax.swing.JOptionPane.showMessageDialog(this, ae.getMessage());
}
initiateCombo(); //adds the objects tot the combo
coBuyer.setSelectedItem(ak.toString());
}
private void initiateCombo() {
PersonDB pdb = new PersonDB();
try {
ArrayList<Persons> buyer = pdb.seekAllBuyers();
for (Persons p : buyer) {
coBuyer.addItem(p);
}
}
【问题讨论】: