I’m getting this warning from the compiler which does not make sense at all (at least to me). It basically wants me to assign a Type to DefaultListModel which is a object type by itself! I’m getting heaps of this warnings all through my code!
C:\Documents and Settings\...\filename.java:345:warning: [rawtypes] found raw type: DefaultListModel
DefaultListModel lm = (DefaultListModel) jList_DataSetList.getModel();
missing type arguments for generic class DefaultListModel<E>
where E is a type-variable:
E extends Object declared in class DefaultListModel
This is another one which I have no idea where is comes from!
C:\Documents and Settings\...\filename.java:897: warning: [rawtypes] found raw type: JList
private javax.swing.JList jList_DataSetList;
missing type arguments for generic class JList<E>
where E is a type-variable:
E extends Object declared in class JList
Thanks in advance
Since Java 7,
DefaultListModelis a generic type, likeList,Set, etc. It expects a type :DefaultListModel<SomeClass>instead of the rawDefaultListModel.This allows to work in a more type-safe way, because you won’t be able to insert a String into a list model which is supposed to contain Integer instances. And you won’t have to cast to Integer when getting an element from the model.
The same is true for
JListwhich is also now aJListof Strings or aJListof Integers, instead of being a rawJList.Read the tutorial about generics, and have a look at the javadoc of DefaultListModel.