4

I'm working on Netbeans and Netbeans has some auto generated object declaration for controllers and some variables. I kept getting the following warnings in the build time. Then I realized from my previous question that Since Java 7, DefaultListModel, JList, Set ... are generic types and need to be provided with their associated type. How come Netbeans didn't generate files to conform with Java7 expectations?! And how can I change code in the auto generated sections to meeet those new conditions?!

C:\Documents and Settings\...somefile.java:902: warning: [rawtypes] found raw type: JList
private javax.swing.JList jList_SystemDSNList;
missing type arguments for generic class JList<E>
where E is a type-variable:
E extends Object declared in class JList

For instance how can I change

private javax.swing.JList jList_DataSetList;

into this,

private javax.swing.JList<E> jList_DataSetList;

When this field is in blue and protected???!! I can change the variable name but it doesn't allow me to change the type!

kleopatra
  • 49,346
  • 26
  • 88
  • 189
Sam
  • 2,552
  • 5
  • 27
  • 43

2 Answers2

3

Select the object in the designer, go to the properties, and select the Code section.

Under "Type Parameters" enter the type you want to declare you list with. Eg. <E> or <String>

If you right-click the object in the designer, and select Customize Code, you can see that declaration and instantiation now include the type parameter.

Mads Nielsen
  • 624
  • 5
  • 16
0

I guess instead of you should provide the data type your JList object is going to store, I don't think any IDE prevent you from changing the source code.

Mike
  • 1,819
  • 5
  • 26
  • 31