gpt4 book ai didi

java - JComboBox.remove 不工作

转载 作者:行者123 更新时间:2023-11-29 07:58:42 24 4
gpt4 key购买 nike

我正在尝试删除 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/

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