gpt4 book ai didi

java - 错误 : unchecked call to DefaultComboBoxModel(E[])

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:12:23 43 4
gpt4 key购买 nike

当我构建/运行由 NetBeans Applet Form 制作的 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”选项有关。

最佳答案

new javax.swing.DefaultComboBoxModel(new String[]

应该替换为

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

这个警告也可以忽略。

关于java - 错误 : unchecked call to DefaultComboBoxModel(E[]),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9401724/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com