What are you doing in setSelectedItem? If a String is getting passed in, you need to map this back to the ObjectX that it corresponds to so that the ObjectX is returned by the next getSelectedItem.
-----Original Message----- From: Reinstein, Lenny [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 2:01 PM To: 'Dmitry Beransky'; '[EMAIL PROTECTED]' Subject: RE: Java Swing/JComboBox Question. You are right, partially Here is the updated question: The reason this happens is that the JComboBox is editable and I use the the text field of the ComboBox to implement auto-complete (I use getEditor().getEditorComponent() to the the text component that corresponds to the editable/selected item). When I do that, the selection always returns String, not the original object that was stored at that index location in the combo box. Does someone know of a way to get around that limitation? Many thanks. -----Original Message----- From: Dmitry Beransky [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 1:40 PM To: '[EMAIL PROTECTED]' Subject: Re: Java Swing/JComboBox Question. To my knowledge, there is nothing in JComboBox that might cause such a behavior. I suspect the problem is somewhere in your code: either in your custom data model or in the code that handles adding items to the model. As the first step, I'd recommend you modify the add method of the model to check what kind of objects are been added. If they are all ObjectX, then you know the problem is in the data model code. Cheers Dmitry At 10:18 AM 1/3/2002, Reinstein, Lenny wrote: >[...] >When I call getItemSelected() the first time, it returns back the >object of type ObjectX, which is what I expect. However, as soon as I >select some other item in the combo box/change the selection, it begins >returning the object of type String, which is not correct. Does anyone >know why? How can fix it? _______________________________________________ Advanced-swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/advanced-swing _______________________________________________ Advanced-swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/advanced-swing _______________________________________________ Advanced-swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/advanced-swing