01: import java.awt.event.ActionListener;
02: import javax.swing.JButton;
03: import javax.swing.JFrame;
04: 
05: /**
06:    This program demonstrates how to install an action listener.
07: */
08: public class ButtonTester
09: {  
10:    public static void main(String[] args)
11:    {  
12:       JFrame frame = new JFrame();
13:       JButton button = new JButton("Click me!");
14:       frame.add(button);
15:      
16:       ActionListener listener = new ClickListener();
17:       button.addActionListener(listener);
18: 
19:       frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
20:       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
21:       frame.setVisible(true);
22:    }
23: 
24:    private static final int FRAME_WIDTH = 100;
25:    private static final int FRAME_HEIGHT = 60;
26: }