Working with Methods
The following sections detail the structure of each event-handling method and the methods that can be used within them.
In addition to the methods described, the getSource() method can be used on any event object to determine which object generated the event.
Action Events
Action events occur when a user completes an action using one of the following components: JButton, JCheckBox, JComboBox, JTextField, or JRadioButton.
A class must implement the ActionListener interface in order to handle these events. In addition, the addActionListener() method must be called on each component that should generate an action event—unless you want to ignore that component's action events.
actionPerformed is the only method in the ActionListener ...
Get Sams Teach Yourself Java 2 in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.