I have this class (call it child
) that extends the JComboBox class from the Swing
library in Java. Now when I create an object of child
and try to call the method addItem(Object)
on it by passing in a String
, I get the following warning:
Type safety: The method addItem(Object) belongs to the raw type JComboBox. References to generic type JComboBox<E> should be parameterized.
What is the proper way of invoking this method? I can't instantiate child
with the generic type of <String>
because child
is not generic; I don't see how else to do this. Any help would be appreciated.
PS. Changing contents of child
is not an option.