ItemListener.itemStateChanged() 中取消选择的项目
当我使用 ItemListener 监听组合框时,我如何知道在 ItemEvent.DESELECTED 被触发时取消选择哪个项目?
When I listens a combobox with ItemListener how can I know, what item was deselected when ItemEvent.DESELECTED is fired?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
ItemEvent .getItem()
Use
ItemEvent.getItem()
您无法直接获取项目索引。解决方法是从
ItemEvent.getItem()
获取取消选择的项目,并通过迭代所有项目来查找索引。You cannot directly get the item index. The workaround is to get the deselected item from
ItemEvent.getItem()
and find the index by iterating over all items.