+ 1

Why do you use this in actionListener???

like.... object reference.addActionListener(this).... what this is doing here???

25th Nov 2016, 2:42 AM
somnath
somnath - avatar
4 Answers
+ 3
actionListener as the name sounds listens for actions especially click and when ENTER BUTTON is pressed. ActionListener class is an abstract class with an abstract method actionPerformed(ActionEvent e) which must be override. whatever code you wrote inside actionPerformed after overriding it will be executed whenever an action is performed (eg button click or Enter button pressed) on the object (eg. Button, TextField) in which the action listener is added
26th Nov 2016, 12:21 AM
damilare lamidi
damilare lamidi - avatar
+ 3
You use that when you implement action listener class. use to refer to the action listener it inherited
12th Apr 2017, 9:28 AM
damilare lamidi
damilare lamidi - avatar
+ 2
An ActionListener is an interface in package java.awt.event . It has only one method void actionPerformed(ActionEvent e)
25th Nov 2016, 4:00 AM
Abdelaziz Abubaker
Abdelaziz Abubaker - avatar
0
lamidi...why do we use this within ()??
26th Nov 2016, 4:24 AM
somnath
somnath - avatar