I've noticed something really quite odd about the JComboBox class. For background, let me say that I'm populating a JComboBox (let's say the instance name is cbMyCombo) with an array of objects (let's call them dataObj class) that have data members:
String name, int id and a toString() method that returns the name. This is working ducky. What irks me is the way the the JComboBox behaves in the container's actionPerfomed() method.
If I do the following:
========================================
========================================
I see that when I trigger an event on cbMyCombo, cbMyCombo.getSelectedItem() returns a dataObj object. In any other case (when any other control fires an event), cbMyCombo.getSelectedItem() returns a string! How can I ensure that I always get a dataObj returned from cbMyCombo.getSelectedItem()? This is really troubling. Thanks for looking at this issue.
Regards,
- DM_Tim