import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class ButtonListener3 implements ActionListener {

    ButtonListener3() {}

    public void actionPerformed( ActionEvent e ) {

	System.out.println( e.getActionCommand().toString() );
    }

    public static void main( String [] args ) {

	ButtonListener3 bl = new ButtonListener3();
        JFrame frame = new JFrame();

	frame.getContentPane().setLayout( new FlowLayout() );

	for (int i=0; i<10; i++) {

	    JButton button = new JButton( "button " + i );

	    button.setActionCommand( "action " + i );
	    button.addActionListener( bl );

	    frame.getContentPane().add( button );
	}

	
        frame.pack();
        frame.requestFocus();
        frame.setVisible(true);
    }

} 
