






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to event handling in java gui programming. It explains the concept of event-driven programming, the role of events and listeners, and the different types of user actions and their corresponding events. The document also covers the java awt event listener interfaces and their methods, as well as handling simple action events using the 'actionperformed' method. Additionally, it discusses alternative approaches to event handling using inner classes.
Typology: Slides
1 / 11
This page cannot be seen from the preview
Don't miss anything!







Source Event Type User Action Object Generated
Click a button JButton ActionEvent
Click a check box JCheckBox ItemEvent, ActionEvent
Click a radio button JRadioButton ItemEvent, ActionEvent
Press return on a text field JTextField ActionEvent
Select a new item JComboBox ItemEvent, ActionEvent
Select an item from a List JList ListSelectionEvent
Window opened, closed, etc. Window WindowEvent
Mouse pressed, released, etc. Any Component MouseEvent
Key released, pressed, etc. Any Component KeyEvent
Handling Simple Action Events
Implementing the listener interface
Registering the frame to be a listener for action events generated by the two buttons
The method for responding to an Action event.
Handling Simple Action Events –
a closer look at the event-handling method
actionPerformed is a method required for all ActionListeners
An Event object’s getSource() method returns a reference to the Component object that generated the event.
Inner class has direct access to all members (even private) of the outer class
Example with anonymous inner classes, one for listening to each button