当我构建/运行我的applet时,从NetBeans Applet表单中获取了2个错误:
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
如果我点击下拉列表,我会在旁边看到一个惊叹号。那是为什么?
此外,这是使用“-Xlint:unchecked”选项。
答案 0 :(得分:11)
new javax.swing.DefaultComboBoxModel(new String[]
应替换为
new javax.swing.DefaultComboBoxModel<String>(new String[]
此警告也可以忽略。