Java – warning: [rawtypes] found original type: defaultlistmodel
I got this warning from the compiler, which makes no sense (at least to me) It basically requires me to assign type to defaultlistmodel, which itself is an object type! I got a lot of warnings 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 I don't know where it 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
Thank you in advance
Solution
Starting from Java 7, defaultlistmodel is a generic type, such as list, set, etc It requires a type: defaultlistmodel < someclass > instead of the original defaultlistmodel
This allows you to work in a more type - safe way because you will not be able to insert a string into a list model that should contain an integer instance You do not have to convert to integer when getting elements from the model
The same is true for JList, which is now also the JList of string or integer, rather than the original JList
Read tutorial about genetics and see Javadoc of defaultlistmodel