Your question and your code don't match. The JComboBox should show the Country's displayName since that is what your enum's toString()
override returns.
And in fact when I test it, that is what I see:
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
public class TestCombo {
public static void main(String[] args) {
JComboBox<Country> countryBox = new JComboBox<Country>(Country.values());
JOptionPane.showMessageDialog(null, new JScrollPane(countryBox));
}
}
enum Country {
AF("af", "Afghanistan"),
US("us", "United States"),
ZW("zw", "Zimbabwe");
private String nameCode;
private String displayName;
private Country(String code, String name) {
this.nameCode = code;
this.displayName = name;
}
public String getNameCode() {
return this.nameCode;
}
public String getDisplayName() {
return this.displayName;
}
@Override
public String toString() {
return this.displayName;
}
}