Java:JRadioButton上的ActionEvent和ItemEvent有什么区别?

编程入门 行业动态 更新时间:2024-10-27 00:32:13
本文介绍了Java:JRadioButton上的ActionEvent和ItemEvent有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

它们都在释放鼠标按钮后被提升一次,并且两者都可以在JRadioButton上获得所有可用的信息,对不对?有什么区别吗?

They're both raised once after the mouse button is released and both can have all the information available on the JRadioButton right? Is there any difference?

推荐答案

一个 setSelected 方法).另一个 ActionListener 当用户与按钮互动时,会调用手(但可以通过 onClick 方法).

An ItemListeners are notified when ever the state of the button is changed, whether through a user interacting with the button or programmatically (via the setSelected method). ActionListeners on the other hand will be called when a user interacts with the button (but can be simulated programmatically via the onClick method).

请注意,与按钮交互(例如单击或击中空格键)的用户也将更改按钮的状态,并引发项目事件和动作事件.通常,您将要定义一个或另一个,不要同时听按钮上的动作事件和项目事件.

Note that a user interacting with the button such as clicking or hitting the space bar will also change the state of the button and raise an item event as well as an action event. Generally, you will want to define either one or the other, don't listen for both action events and item events on the button.

更多推荐

Java:JRadioButton上的ActionEvent和ItemEvent有什么区别?

本文发布于:2023-10-08 02:25:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471244.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么区别   JRadioButton   Java   ItemEvent   ActionEvent

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!