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?
-
Is that ActionListener android or swing?AlexWien– AlexWien2013年02月18日 20:01:30 +00:00Commented Feb 18, 2013 at 20:01
-
Speaking generally, but if it matters the swingImri Persiado– Imri Persiado2013年02月18日 20:03:03 +00:00Commented Feb 18, 2013 at 20:03
1 Answer 1
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.