How Event Handling works o Two open questions from OHow did event handler get registered? ● Answer Through components method addAction Listener OHow does component know to call action Performed? ● Answer: Event is dispatched only to listeners of appropriate type Each event type has corresponding event-listener interface Event ID specifies event type that occurred For example: Mouse Event event's ID spedify which method of the seven events will be handler Introduction to Java Programming, revised by Dai-kaiyuLiang,Introduction to Java Programming,revised by Dai-kaiyu 10 How Event Handling Works ⚫Two open questions from How did event handler get registered? ⚫Answer: • Through component’s method addActionListener How does component know to call actionPerformed? ⚫Answer: • Event is dispatched only to listeners of appropriate type • Each event type has corresponding event-listener interface Event ID specifies event type that occurred For example: MouseEvent event’s ID spedify which method of the seven events will be handler