I have a pretty similar problem like this one Java ComboBox Different Value to Name
I have already changed the code, so I’ll get a Employee-Object (i changed my classnames, since the classnames in the link above are Employee).
In my case, I have already a toString() method, which I don’t want to overwrite. (I need it somewhere else)
But I don’t want to use this toString() method in my JCombobox. But it does automaticaly.
I don’t want to return any strings! I need the objects.
Is there a way to say “take another toString() method, let’s say toStringDifferent()” while creating the JCombobox?
this.comboEmployees = new JComboBox(new EmployeeComboboxModel(getEmployees()));
// this will give me the toString-method's return-value of the Employee object.
// But i want the toStringDifferent() method's result.
thanks!
In fact it is even considered good practice not to use
toString.