Handling Action Events

Action events are fired by subclasses of AbstractButton and includes buttons, checkboxes, and menus.
AbstractButton button = new JButton("OK"); button.addActionListener(new MyActionListener()); public class MyActionListener implements ActionListener { public void actionPerformed(ActionEvent evt) { // Determine which abstract button fired the event. AbstractButton button = (AbstractButton)evt.getSource(); } }

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.