Problem:
Question- How would you modify it? Can you post the modified the code?
class ButtonExample implements ActionListener
{
JButton button1 = new JButton ("Button 1");
JButton button2 = new JButton ("Button 2");
public void actionPerformed(ActionEvent event)
{
System.out.println("I listened");
}
button1.addActionListener(this);
button2.addActionListener(this);
}
Please explain the modified code.