To have a program respond to a mouse click, you should a. write a class called ActionListener with a main() method b. write any actionListener method c. write a class that extends ActionListener d. write a class that implements ActionListener code example

Example 1: actionListener java

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/*in main*/
button.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
			System.out.println('x');
  }
});

Example 2: actionlistener java

JButton Button = new JButton();
Button.setSize(300,300);
Button.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent e) 
    System.out.println(BlockNumber)
  	}
});

Example 3: To have a program respond to a mouse click, you should a. write a class called ActionListener with a main() method b. write any actionListener method c. write a class that extends ActionListener d. write a class that implements ActionListener

To have a program respond to a mouse click, you should:

Tags:

Misc Example