perameterizing a combobox in eclipse makes gui builder give error
I use jdk 1.7 and jre7
I'm using eclipse and im trying out the gui builder and i like it better than netbeans but when i make a combobox i get the warning to parameterize it so i do and then i look at the design window and it gives this error
new JComboBox<String>(targetElement) is not valid source for component creation, it references not existing constructor.
when i dont parameterize it its fine is there any way to fix this? this is the code for the combobox without the parameter
Code :
String[] targetElement = {"Choose", "None", "Earth", "Wind", "Water", "Fire"};
JComboBox comboBox_3 = new JComboBox(targetElement);
comboBox_3.setFont(new Font("Tahoma", Font.BOLD, 11));
panel.add(comboBox_3);
i guess its fine without but just curious on if this will cause problems if i dont parameterize or if i can just leave it without and be fine?
Re: perameterizing a combobox in eclipse makes gui builder give error
If you are going to declare a type parameter in the constructor, you also have to do it in the variable declaration. For example:
ArrayList<Object> list = new ArrayList<>();
Re: perameterizing a combobox in eclipse makes gui builder give error
Your problem is that your Eclipse Java compliance level is set to 1.6 or lower, and you've got to set your it to Java 1.7. You can do this for all of Eclipse by clicking on the Window menu, or on a project by project basis by right clicking on the project. Go into the set up menu, and into Java then Compiler and there set the compliance level.