You are adding an "object" to your JComboBox. Yet your image and string are 2 different objects. When you do this, the image object is implicitly converting to string hence the filename rather than the image itself.
I suggest 1) use a model when creating your combo box, or 2) use a Javabean embedding the image and description, or 3) use an array.
You need 2 things:
1) You need to have a separate class that will hold the image and string value. You can then add this object to the addItem() method.
2) Then, you need to write a Renderer - A renderer controls how the items are 'displayed' - you can tweak the display as per your needs.
To know more about renderers, check out the tutorial
SCJP 1.4, OCMJEA/SCEA 5.0.
Joined: May 17, 2012
That's great information. The tutorial is particularly useful.
Thank you both for your help.
subject: Showing a string and then an icon at the same time in a JComboBox.