import java.awt.*;
import java.util.Arrays;

import javax.swing.*;


public class Puissance4 extends JFrame{
	private int NB_COL=7;
	private int NB_LIG=6;
	private JLabel[][] Game;
	
	private ImageIcon rouge = new ImageIcon("rouge.jpg");
	private ImageIcon jaune = new ImageIcon("jaune.jpg");
	
	
	public Puissance4 (int col, int lig){
		NB_COL=col;
		NB_LIG=lig;
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		this.setLayout(new GridLayout(NB_LIG,NB_COL));
		
		
		for(int i=0; i<NB_COL; i++){
			JButton filler = new JButton();
		
			// set up the jbutton
			filler.setIcon(new ImageIcon("blanc.jpg"));
			filler.setRolloverEnabled(true);

			// create an instance of the RolloverIcon class when calling setRolloverIcon
			filler.setRolloverIcon(new ImageIcon("drop.jpg"));
			
			add(filler);
		}
		
		JLabel[][] Game = new JLabel[NB_LIG][NB_COL];
		
		for(int i=0; i<NB_LIG-1; i++){
			for(int j=0; j<NB_COL; j++){
		JLabel filler2 = new JLabel(new ImageIcon("vide.jpg"));
		Game[i][j]=filler2;
			}
			
		}
		
		for(int i=0; i<NB_LIG-1; i++){
			for(int j=0; j<NB_COL; j++){
				  add(Game[i][j]);
			}
		}
	
		
		this.pack();
		this.setVisible(true);
	}
		
	public Puissance4(){
		 new Puissance4(NB_COL,NB_LIG);
		}
		

		void TakeYellow(int col, int lig){
			Game[lig][col].setIcon(jaune);
			this.pack();
		}
		
		void TakeRed(int col, int lig){
			Game[lig][col].setIcon(rouge);
			this.pack();
		}
}

