import javax.swing.*;

import java.awt.*;

public class IHMCompteur extends JFrame {
	
	private JPanel boutons = new JPanel();
	private Compteur cmp = new Compteur();
	private JLabel texte = new JLabel("Compteur : " + cmp.getCpt());
	private JButton boutonPlus = new JButton("+1");
	private JButton boutonMoins = new JButton("-1");
	private JButton boutonZero = new JButton("Remise à zéro");
	private InDecListener idl = new InDecListener(cmp,texte);
	
	public IHMCompteur(String titre) {
		super(titre);		
		this.setPreferredSize(new Dimension(400,100));
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.texte.setHorizontalAlignment(JLabel.CENTER);
		boutonPlus.addActionListener(idl);
		boutonMoins.addActionListener(idl);
		boutonZero.addActionListener(idl);
		this.boutons.setLayout(new GridLayout(1,3));
		this.boutons.add(boutonMoins);
		this.boutons.add(boutonZero);
		this.boutons.add(boutonPlus);
		this.getContentPane().setLayout(new GridLayout(2,1));
		this.getContentPane().add(texte);
		this.getContentPane().add(boutons);
		
		
	}

}
