从 JComboBox 的侦听器中删除元素

发布于 2024-12-04 05:35:42 字数 224 浏览 4 评论 0原文

我有一个组合框,其中包含某些元素,例如:“abc”,“pqr”,现在当用户键入“a”时,我希望刷新组合框并删除其所有元素,然后再次仅添加那些开始的元素与用户字符串。 (这些元素存储在数组中)

我尝试修改“addCaretListener”中的元素,但它抛出“java.lang.IllegalStateException:尝试在通知中进行变异”异常

是否有特定的方法来实现此目的?

谢谢

I have a combobox, with certain elements within it, eg: "abc", "pqr", now when the user types "a", I wish to refresh the combobox and remove all its elements and then again add only those elements which start with the user string. (These elements are stored in a array)

I tried in to modify its elements in "addCaretListener" but it throws "java.lang.IllegalStateException: Attempt to mutate in notification" Exception

Is there a specific way to implement this?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文