JComboBox,当我需要在选择状态(不必是新的)后捕获鼠标单击时,什么侦听器?

发布于 2024-11-17 14:35:29 字数 154 浏览 5 评论 0原文

无法使用 ItemListener 因为我的 JComboBox 项目是动态生成的,因此当列表为空时会生成异常。 我需要基本上捕获某个项目上的鼠标单击事件后的状态(MouseListener 的问题是,即使我打开 JComboBox 中的项目列表,它也会捕获该事件)。

Can't use an ItemListener because my JComboBox items are generated dinamically so that would generate exceptions when the list is empty.
I need to catch basically the state after a mouse click event on an item (the problem with MouseListener is that it catches the event even when I open the list of items in the JComboBox).

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以可爱出名 2024-11-24 14:35:29

尝试使用ActionListener

请参阅如何使用组合框。特别是处理组合框上的事件部分。

Try to use ActionListener.

See How to Use Combo Boxes. Especially Handling Events on a Combo Box section.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文