Event
- in the VisualizingLinkedLists applet, whenever you scroll or resize your display screen, the animation starts
- what is going on? something is happening
- doing multiple task at the same time
- Thread : "A thread is a thread of execution in a program"
- applets and GUI event handling inherently use multiple threads
- we will adopt the first rule of using threads: "avoid them when you can"
- learn more when you study topics like concurrent programming and animation
- Delegation-based Model
- Any component can be notified of the event. All it has to do is implement the appropriate interface and be registered as an event listener on the appropriate event source.
- Listeners "listen" for an event. When an event occurs, the listener identifies the target of the event, then delegates the processing of the event to the proper event handler. Each object in a program upon which events can be generated "register" themselves with one or more listeners.
- Different types of listeners listen for different types of events
- ActionListener
- clicks a Button, or presses Return while typing in a text field
- WindowListener
- closes a windows Frame
- MouseListener
- presses a mouse button while the cursor is over a component
- ItemListener
- selects List or Choice items