import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class sSwing3 {
	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 sSwing3

class myListener implements ActionListener {
	public void actionPerformed(ActionEvent e) {
		System.out.println("Command="+e.getActionCommand());
		new Thread(new myHandlingThread()).start();
	} //actionPerformed()
} //class myListener
	
class myHandlingThread implements Runnable {
	public void run() {
		System.out.println("Action handling done by thread "+Thread.currentThread().getName()+" started ..." );		
		try {
			Thread.sleep(5000);
		} catch (Exception e) {}
		System.out.println("Action handling done by thread "+Thread.currentThread().getName()+" ... ended" );
	} //run()
} //class myHandlingThread