我正在尝试删除 JComboBox 中的选定项目(我已经添加了设计时间)但是没有执行删除功能。我做错了什么
// jComboBox1.removeAllItems(); working
// jComboBox1.removeItem(jComboBox1.getSelectedItem()); working
jComboBox1.remove(jComboBox1.getSelectedIndex()); not working
最佳答案
Class JComboBox
中没有这样的方法remove
。
您想使用 public void removeItemAt(int anIndex) :
Removes the item at anIndex This method works only if the JComboBox uses a mutable data model.
jComboBox1.removeItemAt(jComboBox1.getSelectedIndex());
关于java - JComboBox.remove 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15903116/