I have the following code:
JButton button = new JButton(\"Clear\");
button.addActionListener(this);
As far as I understand I create a butto
The event generator is told about the object which can handle its events Event Generators have a method; — addActionListener(reference to the object of Handler class) For example,
JButton b1=new JButton("My Button");
b1.addActionListener(this); // Please note listener and generator are same class
Since event handler is in same object that contains
button, so we have to use this to pass the reference.