我的代码如下所示:
private void populateRoleNameComboBox() {
roleNameJComboBox.removeAllItems();
roleNameJComboBox.addItem(UserAccountDirectory.ADMIN_ROLE);
roleNameJComboBox.addItem(UserAccountDirectory.SALESPERSON_ROLE);
roleNameJComboBox.addItem(UserAccountDirectory.SUPPLIER_ROLE);
roleNameJComboBox.addItem(UserAccountDirectory.CUSTOMER_ROLE);
//populatePersonNameComboBox();
}
private void populatePersonNameComboBox() {
personNameJComboBox.removeAllItems();
if(roleNameJComboBox.getSelectedItem().equals(UserAccountDirectory.SUPPLIER_ROLE)){
for(Supplier s : supplierDirectory.getSupplierList()){
personNameJComboBox.addItem(s);
}
}
else if(roleNameJComboBox.getSelectedItem().equals(UserAccountDirectory.SALESPERSON_ROLE)){
for(Person p : employeeDirectory.getSalesPersonList()){
personNameJComboBox.addItem(p);
}
}
else if(roleNameJComboBox.getSelectedItem().equals(UserAccountDirectory.CUSTOMER_ROLE)){
for(Person person : customerDirectory.getCustomerList()){
personNameJComboBox.addItem(person);
}
}
}
我的 personNameJComboBox 没有显示任何值。如何实现逻辑以根据第一个组合框获取第二个组合框的值。