
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class Compteur extends JFrame {
	
	private JButton myButton;
	private int countah;
	
	public Compteur() {
			countah=5;
			myButton = new JButton(Integer.toString(countah));
			myButton.addActionListener(new FirstListener()) ;
			this.getContentPane().add(myButton);
			this.pack();
			this.setVisible(true);
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	class FirstListener implements ActionListener {
		public void actionPerformed ( ActionEvent e) 
		{
			countah++;
			myButton.setText (Integer.toString(countah)); 
			pack();
		}
	}

}