Handling User Events
When a user event is generated by a component that has a listener, a method is called automatically. The method must be found in the class specified when the listener was attached to the component.
Each listener has different methods that are called to receive their events. The ActionListener interface sends events to a method called actionPerformed(). The following is a short example of an actionPerformed() method:
public void actionPerformed(ActionEvent event) { // method goes here}
All action events sent in the program go to this method. If only one component in a program can possibly send action events, you can put statements in this method to handle the event. If more than one component can send these events, you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access