JComboBox is a raw type. References to generic type JComboBox<E> should be parameterized

25,769

Solution 1

You can use:

JComboBox<String> box = new JComboBox<>(boxOptions);

This happens because JComboBox is now a generic class.

Solution 2

As of Java 7, generics were introduced into JComboBox component. Maybe you were using Java6 before. You should add JComboBox<String> to the second line there.

Share:
25,769
tssguy123
Author by

tssguy123

Updated on March 16, 2020

Comments

  • tssguy123
    tssguy123 about 4 years
    String[] boxOptions = {"1","2","4","8","16","20","40","100","400"};
    JComboBox box = new JComboBox(boxOptions);
    

    I had these exact lines of code in my program before, and wasn't getting this error. I did a bit of searching and the results I found are going a bit over my head. Any ideas?

    The error is:

    JComboBox is a raw type. References to generic type JComboBox<E> should be parameterized
    
  • tssguy123
    tssguy123 over 10 years
    Strange. It looks like one of the projects was using JRE7 and one is using JavaSE-1.7...