0

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?

2
  • Is that ActionListener android or swing? Commented Feb 18, 2013 at 20:01
  • Speaking generally, but if it matters the swing Commented Feb 18, 2013 at 20:03

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.