Specifications
Sun Services
Java™ Programming Language
Module 11, slide 8 of 22
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
A Listener Example
19
20 public static void main(String args[]) {
21 TestButton guiApp = new TestButton();
22 guiApp.launchFrame();
23 }
24 }
Code for the event listener looks like this:
1 import java.awt.event.*;
2
3 public class ButtonHandler implements ActionListener {
4 public void actionPerformed(ActionEvent e) {
5 System.out.println("Action occurred");
6 System.out.println("Button’s command is: "
7 + e.getActionCommand());
8 }
9}










