它们都在释放鼠标按钮后被提升一次,并且两者都可以在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有什么区别?
发布评论