import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;


public class Hello extends JFrame implements ActionListener {
	JButton button = new JButton("Action");
	JLabel label = new JLabel("0");
	
	void init(){
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(new FlowLayout());
		add(label);
		add(button);
		button.addActionListener(new ActionListener(){
			int index = 1;
			public void actionPerformed(ActionEvent e) {
				label.setText("" + index++);			
			}
		});
//		button.addActionListener(new HelloListener(label));
		button.addActionListener(this);
	}
	
	public static void main(String args[]){
		Hello hello = new Hello();
		hello.init();
		hello.pack();
		hello.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		System.exit(0);
	}
}

class HelloListener implements ActionListener {
	private JLabel lablutu = null;
	
	public HelloListener(JLabel l){
		lablutu = l;
	}
	
	public void actionPerformed(ActionEvent e) {
		lablutu.setText("Labelosu");
	}
	
}
