import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class sSwing21 {
	public static void main(String argv[]) {
		JFrame f = new JFrame("simple Swing");
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		Container container = f.getContentPane();
		container.setLayout(new GridLayout(0, 1));
		JButton b1 = new JButton("click me!");
		container.add(b1);
		JButton b2 = new JButton(".. or me!");
		container.add(b2);

		myListener myL = new myListener();
		
		b1.addActionListener( myL );
	 	b2.addActionListener( myL );
		
		f.setLocation(300, 50);
		f.setSize(150, 200);
		f.setVisible(true);
	} //main()
} //class sSwing21

class myListener implements ActionListener {
	public void actionPerformed(ActionEvent e) {
		System.out.println("Action handling started");
		try {
			Thread.sleep(5000);
		} catch (InterruptedException ie) {
			System.out.println("an InterruptedException occurred\n"+ie.toString()+"\n"+ie.getMessage() );
		} //catch				
		System.out.println("Action handling ended");
	} //actionPerformed()
} //class myListener
	