Imri Persiado
Imri Persiado

Reputation: 1889

Implementing interfaces

I know what interface is and how to build/use one. Lets take the ActionListener interface for example. My question is what happens after I click on a button, which class calls the actionPerformed method?what is the process from the part that I click the button to the part that the actionPerformed is executed?

Upvotes: 0

Views: 76

Answers (1)

JB Nizet
JB Nizet

Reputation: 691735

The JButton calls the ActionListener.

Internally, it listens to keyboard and mouse events. When it receives a mouse click or a keypress which means "click the button", it creates an ActionEvent instance, loops through all the ActionListener instances that have been added to itself, and calls each one with the ActionEvent as argument.

Upvotes: 1

Related Questions