Introduction to AWT and Applets · Introduction to Java Programming

Event Handling

Watch lectures

Event Handling

1. What Is an Event? (beginner)

Event = user did something (clicked, typed, closed!). Handling = code runs in reply (button → bill!). Flow: source (button!) → event object (ActionEvent!) → listener (your code!).

Button (source!) --click--> ActionEvent (what/where!) --dispatch--> actionPerformed() (your reply!)

Three steps: implement → register (addXListener) → handle (callback!).

4. Traps

  • Forgot addActionListener → click does NOTHING (most common!).
  • Wrong method name (actionperformd) → no override (use @Override to catch!).
  • Long work in handler freezes UI (use thread!).

5. Exam Points

  • Counter program + 3 steps — 7 marks, very frequent.
  • Delegation flow — 3-5 marks, frequent.
Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

← All Introduction to Java Programming modules