Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: unchecked call to DefaultComboBoxModel(E[])

When I build / run my applet, made from the NetBeans Applet Form I get 2 errors:

warning: [unchecked] unchecked call to DefaultComboBoxModel(E[]) as a member of the raw type DefaultComboBoxModel
        levelBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7" }));
  where E is a type-variable:
    E extends Object declared in class DefaultComboBoxModel
warning: [unchecked] unchecked call to setModel(ComboBoxModel<E>) as a member of the raw type JComboBox
        levelBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7" }));
  where E is a type-variable:
    E extends Object declared in class JComboBox
2 warnings

If I click on the dropdown I get an exclamation mark next to it. Why is that?

Also, this is with the "-Xlint:unchecked" option.

like image 604
Squeazer Avatar asked Feb 22 '12 19:02

Squeazer


1 Answers

new javax.swing.DefaultComboBoxModel(new String[]

should be replaced by

new javax.swing.DefaultComboBoxModel<String>(new String[]

This warning can be ignored as well.

like image 161
Ashwinee K Jha Avatar answered Sep 22 '22 07:09

Ashwinee K Jha