开发者

What exactly this method do ? addActionListener

开发者 https://www.devze.com 2023-04-11 14:29 出处:网络
What exactly will this addActionListener Do.....we 开发者_运维知识库we call button.addActionListener(this) what will happenIt basically adds this (the current object) to a list of objects that will be

What exactly will this addActionListener Do.....we 开发者_运维知识库we call button.addActionListener(this) what will happen


It basically adds this (the current object) to a list of objects that will be notified when the component has an action performed on it, such as a button being pressed.

It's a way of registering your interest in what is happening to the component and is useful in that you don't have to keep polling a component to check its status.

Your object (or class, really) simply implements the interface methods for listening (such as actionPerformed) and that method will be called for each event that happens.

The Java tutorials have a large variety of different articles on the various listeners that you're likely to use.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号