At 02:37 PM 1/3/2002, Reinstein, Lenny wrote:
>Just an fyi, one of the colleagues of mine suggested this solution:
>overwrite the equals method in the custom class I was using. Amazingly, it
>solved the problem.
It's not really amazing if you look at the source code of
DefaultComboBoxModel.setSelectedItem() :-)
public void setSelectedItem(Object anObject) {
if ( (selectedObject != null && !selectedObject.equals( anObject )) ||
selectedObject == null && anObject != null ) {
selectedObject = anObject;
fireContentsChanged(this, -1, -1);
}
}
What your colleague had suggested, IMHO, is not a solution, but a
hack. That's why I didn't mention it. 1) you shouldn't override the
equals method, unless the objects are really equal, that is, can be used
interchangeably throughout your code; 2) this will only work if the string
corresponds to the currently selected item (which happens to be the case in
your implementation).
Cheers
Dmitry
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing