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

 


public class KalahaGUI extends JFrame {
 
  
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public KalahaGUI( final Kalaha kalaha) {
    	game = kalaha;
        initComponents();
    }
    
   
   //En este metodo el diseņo de las ventanas se establece aņadiendo y colocando botones, 
   //zonas de texto, campos de texto,etc. 
   //Tambien mouse listeners se asignan a los botones
    private void initComponents() {
     
    	
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jButton17 = new javax.swing.JButton();
        jButton18 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        jButton20 = new javax.swing.JButton();
        jButton21 = new javax.swing.JButton();
        jButton22 = new javax.swing.JButton();
        jButton23 = new javax.swing.JButton();
        jButton24 = new javax.swing.JButton();
        jButton25 = new javax.swing.JButton();
        jButton26 = new javax.swing.JButton();
        jButton27 = new javax.swing.JButton();
        jButton28 = new javax.swing.JButton();
        jButton29 = new javax.swing.JButton();
        jButton30 = new javax.swing.JButton();
        
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        entrada = new JTextField();
        entrada2 = new JTextField();
        
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        
        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.setBackground(new Color(241,236,107));
        jScrollPane1.setViewportView(jTextArea1);
        
       
        Container pane = getContentPane();
        pane.setLayout(new BorderLayout());
        pane.setSize(1000, 700);
        
        jButton1.setLocation(775,70);
        jButton1.setSize(80,110);
        jButton1.setBackground(new Color(200,120,0));
    	jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton1.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton1.setVerticalTextPosition(SwingConstants.TOP);
    	jButton1.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton1.setForeground(Color.yellow);
    	jButton1.setOpaque(false);
        jButton1.setBorderPainted(false);
        pane.add(jButton1);
        
        jButton2.setLocation(650,70);
        jButton2.setSize(80,110);
        jButton2.setBackground(new Color(200,120,0));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton2.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton2.setVerticalTextPosition(SwingConstants.TOP);
    	jButton2.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton2.setForeground(Color.yellow);
    	jButton2.setOpaque(false);
        jButton2.setBorderPainted(false);
        pane.add(jButton2);
        
        jButton3.setLocation(525,70);
        jButton3.setSize(80, 110);
        jButton3.setBackground(new Color(200,120,0));
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton3.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton3.setVerticalTextPosition(SwingConstants.TOP);
    	jButton3.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton3.setForeground(Color.yellow);
    	jButton3.setOpaque(false);
    	jButton3.setBorderPainted(false);
        pane.add(jButton3);
        
        jButton4.setLocation(400,70);
        jButton4.setSize(80, 110);
        jButton4.setBackground(new Color(200,120,0));
        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton4.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton4.setVerticalTextPosition(SwingConstants.TOP);
    	jButton4.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton4.setForeground(Color.yellow);
    	jButton4.setOpaque(false);
        jButton4.setBorderPainted(false);
        pane.add(jButton4);
        
        jButton5.setLocation(275,70);
        jButton5.setSize(80, 110);
        jButton5.setBackground(new Color(200,120,0));
        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton5.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton5.setVerticalTextPosition(SwingConstants.TOP);
    	jButton5.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton5.setForeground(Color.yellow);
    	jButton5.setOpaque(false);
        jButton5.setBorderPainted(false);
        pane.add(jButton5);
        
        jButton6.setLocation(150,70);
        jButton6.setSize(80, 110);
        jButton6.setBackground(new Color(200,120,0));
        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton6.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton6.setVerticalTextPosition(SwingConstants.TOP);
    	jButton6.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton6.setForeground(Color.yellow);
    	jButton6.setOpaque(false);
        jButton6.setBorderPainted(false);
        pane.add(jButton6);
        
        jButton7.setLocation(15,195);
        jButton7.setSize(160, 90);
        jButton7.setBackground(new Color(200,120,0));
        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/manca2.jpg")));
    	jButton7.setHorizontalTextPosition(SwingConstants.LEFT);
    	jButton7.setVerticalTextPosition(SwingConstants.CENTER);
    	jButton7.setFont(new java.awt.Font("Calibri", 10, 20));
    	//jButton7.setForeground(Color.yellow);
    	jButton7.setOpaque(false);
        jButton7.setBorderPainted(false);
        pane.add(jButton7);
        
        jButton8.setLocation(150,300);
        jButton8.setSize(80, 110);
        jButton8.setBackground(new Color(200,120,0));
        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton8.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton8.setVerticalTextPosition(SwingConstants.BOTTOM);
    	jButton8.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton8.setForeground(Color.yellow);
    	jButton8.setOpaque(false);
        jButton8.setBorderPainted(false);
        pane.add(jButton8);
        
        jButton9.setLocation(275,300);
        jButton9.setSize(80, 110);
        jButton9.setBackground(new Color(200,120,0));
        jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton9.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton9.setVerticalTextPosition(SwingConstants.BOTTOM);
    	jButton9.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton9.setForeground(Color.yellow);
    	jButton9.setOpaque(false);
        jButton9.setBorderPainted(false);
        pane.add(jButton9);
        
        jButton10.setLocation(400,300);
        jButton10.setSize(80, 110);
        jButton10.setBackground(new Color(200,120,0));
        jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton10.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton10.setVerticalTextPosition(SwingConstants.BOTTOM);
    	jButton10.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton10.setForeground(Color.yellow);
    	jButton10.setOpaque(false);
        jButton10.setBorderPainted(false);
        pane.add(jButton10);
        
        jButton11.setLocation(525,300);
        jButton11.setSize(80, 110);
        jButton11.setBackground(new Color(200,120,0));
        jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton11.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton11.setVerticalTextPosition(SwingConstants.BOTTOM);
    	jButton11.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton11.setForeground(Color.yellow);
    	jButton11.setOpaque(false);
        jButton11.setBorderPainted(false);
        pane.add(jButton11);
        
        jButton12.setLocation(650,300);
        jButton12.setSize(80, 110);
        jButton12.setBackground(new Color(200,120,0));
        jButton12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton12.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton12.setVerticalTextPosition(SwingConstants.BOTTOM);
    	jButton12.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton12.setForeground(Color.yellow);
    	jButton12.setOpaque(false);
        jButton12.setBorderPainted(false);
        pane.add(jButton12);
        
        jButton13.setLocation(775,300);
        jButton13.setSize(80, 110);
        jButton13.setBackground(new Color(200,120,0));
        jButton13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/mancal.jpg")));
    	jButton13.setHorizontalTextPosition(SwingConstants.CENTER);
    	jButton13.setVerticalTextPosition(SwingConstants.BOTTOM);
    	jButton13.setFont(new java.awt.Font("Calibri", 10, 29));
    	//jButton13.setForeground(Color.yellow);
    	jButton13.setOpaque(false);
        jButton13.setBorderPainted(false); 
        pane.add(jButton13);
        
        jButton14.setLocation(835,195);
        jButton14.setSize(160, 90);
        jButton14.setBackground(new Color(200,120,0));
        jButton14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/manca2.jpg")));
    	jButton14.setHorizontalTextPosition(SwingConstants.RIGHT);
    	jButton14.setVerticalTextPosition(SwingConstants.CENTER);
    	jButton14.setFont(new java.awt.Font("Calibri", 10, 20));
    	//jButton14.setForeground(Color.yellow);
    	jButton14.setOpaque(false);
        jButton14.setBorderPainted(false);
        pane.add(jButton14);
        
        
        jButton15.setLocation(250,150);
        jButton15.setSize(500, 100);
        jButton15.setBackground(new Color(200,120,0));
        jButton15.setBorderPainted(false);
        pane.add(jButton15);
        
        jButton16.setLocation(250,250);
        jButton16.setSize(500, 100);
        jButton16.setBackground(new Color(200,120,0));
        jButton16.setBorderPainted(false);
        pane.add(jButton16);
        
        jButton17.setLocation(250,350);
        jButton17.setSize(500, 100);
        jButton17.setBackground(new Color(200,120,0));
        jButton17.setBorderPainted(false);
        pane.add(jButton17);
        
        jButton18.setLocation(250,200);
        jButton18.setSize(500, 100);
        jButton18.setBackground(new Color(200,120,0));
        jButton18.setBorderPainted(false);
        pane.add(jButton18);
        
        jButton19.setLocation(250,300);
        jButton19.setSize(500, 100);
        jButton19.setBackground(new Color(200,120,0));
        jButton19.setBorderPainted(false);
        pane.add(jButton19);
        
        jButton20.setLocation(650,245);
        jButton20.setSize(100, 50);
        jButton20.setBackground(new Color(200,120,0));
        jButton20.setBorderPainted(false);
        pane.add(jButton20);
        
        jButton21.setLocation(150,200);
        jButton21.setSize(150, 75);
        //jButton21.setBackground(new Color(200,120,0));
        jButton21.setBorderPainted(false);
        pane.add(jButton21);
        
        jButton22.setLocation(325,200);
        jButton22.setSize(150, 75);
        //jButton22.setBackground(new Color(200,120,0));
        jButton22.setBorderPainted(false);
        pane.add(jButton22);
        
        jButton23.setLocation(500,200);
        jButton23.setSize(150, 75);
        //jButton23.setBackground(new Color(200,120,0));
        jButton23.setBorderPainted(false);
        pane.add(jButton23);
        
        jButton24.setLocation(675,200);
        jButton24.setSize(150, 75);
        //jButton24.setBackground(new Color(200,120,0));
        jButton24.setBorderPainted(false);
        pane.add(jButton24);

        jButton25.setLocation(270,200);
        jButton25.setSize(500, 100);
        jButton25.setBackground(new Color(200,120,0));
        jButton25.setBorderPainted(false);
        jButton25.setOpaque(false);
        pane.add(jButton25);
        
        jButton26.setLocation(270,300);
        jButton26.setSize(500, 100);
        jButton26.setBackground(new Color(200,120,0));
        jButton26.setBorderPainted(false);
        jButton26.setOpaque(false);
        pane.add(jButton26);

        jButton27.setLocation(160,300);
        jButton27.setSize(125, 75);
        //jButton27.setBackground(new Color(200,120,0));
        jButton27.setBorderPainted(false);
        pane.add(jButton27);
        
        jButton28.setLocation(335,300);
        jButton28.setSize(125, 75);
        //jButton28.setBackground(new Color(200,120,0));
        jButton28.setBorderPainted(false);
        pane.add(jButton28);
        
        jButton29.setLocation(510,300);
        jButton29.setSize(125, 75);
        //jButton29.setBackground(new Color(200,120,0));
        jButton29.setBorderPainted(false);
        pane.add(jButton29);
        
        jButton30.setLocation(685,300);
        jButton30.setSize(125, 75);
        //jButton30.setBackground(new Color(200,120,0));
        jButton30.setBorderPainted(false);
        pane.add(jButton30);
                
        pane.add(new JScrollPane(jTextArea1), BorderLayout.SOUTH);

        entrada.setLocation(350, 350);
        entrada.setSize(300,25);
        pane.add(entrada);
        
        entrada2.setLocation(350, 350);
        entrada2.setSize(300,25);
        entrada2.setVisible(false);
        pane.add(entrada2);
        
        
        
        entrada.setVisible(false);
        jButton1.setVisible(false);
        jButton2.setVisible(false);
        jButton3.setVisible(false);
        jButton4.setVisible(false);
        jButton5.setVisible(false);
        jButton6.setVisible(false);
        jButton7.setVisible(false);
        jButton8.setVisible(false);
        jButton9.setVisible(false);
        jButton10.setVisible(false);
        jButton11.setVisible(false);
        jButton12.setVisible(false);
        jButton13.setVisible(false);
        jButton14.setVisible(false);
        jButton15.setVisible(false);
        jButton16.setVisible(false);
        jButton17.setVisible(false);
        jButton18.setVisible(false);
        jButton19.setVisible(false);
        jButton20.setVisible(false);
        jButton21.setVisible(false);
        jButton22.setVisible(false);
        jButton23.setVisible(false);
        jButton24.setVisible(false);
        jButton25.setVisible(false);
        jButton26.setVisible(false);
        jButton27.setVisible(false);
        jButton28.setVisible(false);
        jButton29.setVisible(false);
        jButton30.setVisible(false);
        
        pane.setBackground(new Color(180,80,0));
// imagen de fondo
        JLabel ima = new JLabel(new ImageIcon(getClass().getResource("imagenes/fondo.png"))); 
        pane.add(ima);     

        closeeleccionDialog();
        setVisible(true);
        setTitle("KALAHA");
        this.setMinimumSize(new Dimension(1000,600));
        //this.setBounds(new Rectangle(20,20,1000,900));
     
        jButton1.addMouseListener(new ButtonClick()
              {
                	public void mouseClicked(MouseEvent e)
        			{
                		
                    	            	
                    		   game.entradahoyoeleccion("0");
                    	                    		
                    	
        			}
        			
               }
           );
         jButton2.addMouseListener(new ButtonClick()
              {
        	 public void mouseClicked(MouseEvent e)
 			{
         		
         		   game.entradahoyoeleccion("1");
         		
 			}
        			
               }
           );
          jButton3.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		
                		   game.entradahoyoeleccion("2");
                		
        			}
        			
                }
            );
           jButton4.addMouseListener(new ButtonClick()
           {
        	   public void mouseClicked(MouseEvent e)
   			{
           		
           			game.entradahoyoeleccion("3");
           		
   			}
   			}
        			
                
                );
                jButton5.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		
                			game.entradahoyoeleccion("4");
                		
        			}
        			
                }
                );
                jButton6.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		
                		   game.entradahoyoeleccion("5");
                	
        			}
        			
                }
                );
                jButton8.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		
                			game.entradahoyoeleccion("7");
                		
        			}
        			
                }
                );
                jButton9.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		
                			game.entradahoyoeleccion("8");
                		
        			}
        			
                }
                );
                jButton10.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		
                			game.entradahoyoeleccion("9");
                		
        			}
        			
                }
                );
                jButton11.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		
                		   game.entradahoyoeleccion("10");
                		
        			}
        			
                }
                );
                jButton12.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		
                		   game.entradahoyoeleccion("11");
                		
        			}
        			
                }
                );
                jButton13.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		
                			game.entradahoyoeleccion("12");
                		
        			}
        			
                }
                );
                jButton15.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.entradanivel("1");
        			}
        			
                }
                );
                jButton16.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.entradanivel("2");
        			}
        			
                }
                );
                jButton17.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.entradanivel("3");
        			}
        			
                }
                );
                
                jButton18.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.entradaeleccion("y");
        			}
        			
                }
                );
                
                jButton19.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.entradaeleccion("n");
        			}
        			
                }
                );
                
                jButton20.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		
        			}
        			
                }
                );
                jButton21.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		 game.PIEDRAS = 6;
                		 game.HOYOS = 6;

        			}
        			
                }
                );
                jButton22.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.PIEDRAS = 5;
                		game.HOYOS = 6;
        			}
        			
                }
                );jButton23.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.PIEDRAS = 4;
                		game.HOYOS = 6;
        			}
        			
                }
                );jButton24.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.PIEDRAS = 3;
                		game.HOYOS = 6;
        			}
        			
                }
                );jButton25.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.humano = true;
                		game.control = true;
        			}
        			
                }
                );jButton26.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.humano = false;
                		game.control = true;
        			}
        			
                }
                );jButton27.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		 game.PIEDRAS = 6;
                		 game.HOYOS = 5;

        			}
        			
                }
                );
                jButton28.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.PIEDRAS = 5;
                		game.HOYOS = 5;
        			}
        			
                }
                );jButton29.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.PIEDRAS = 4;
                		game.HOYOS = 5;
        			}
        			
                }
                );jButton30.addMouseListener(new ButtonClick()
                {
                	public void mouseClicked(MouseEvent e)
        			{
                		game.PIEDRAS = 3;
                		game.HOYOS = 5;
        			}
        			
                }
                );
                
        pack();
    }// </editor-fold>
    // recupera las piedras de un agujero del tablero. 
    
    private String getpiedrasTablero(int hoyo_number)
    {
    	String stones = null;
    	
    	   stones = "" + game.posicionActual.tablero[hoyo_number]; 
    	
    	return stones ;
    }
    //aņade texto a los botones. El texto son las piedras en el correspondiente hoyo del tablero. 
    public void TextoBotones()
    {
    	if (game.HOYOS==5){
    		
        	jButton1.setText(getpiedrasTablero(0));
        	
            jButton2.setText(getpiedrasTablero(1));

            jButton3.setText(getpiedrasTablero(2));

            jButton4.setText(getpiedrasTablero(3));

            jButton5.setText(getpiedrasTablero(4));

            jButton7.setText(getpiedrasTablero(5));

            jButton8.setText(getpiedrasTablero(6));

            jButton9.setText(getpiedrasTablero(7));

            jButton10.setText(getpiedrasTablero(8));

            jButton11.setText(getpiedrasTablero(9));

            jButton12.setText(getpiedrasTablero(10));

            jButton14.setText(getpiedrasTablero(11));

    	}else{
    	jButton1.setText(getpiedrasTablero(0));

    	jButton2.setText(getpiedrasTablero(1));

        jButton3.setText(getpiedrasTablero(2));

        jButton4.setText(getpiedrasTablero(3));

        jButton5.setText(getpiedrasTablero(4));

        jButton6.setText(getpiedrasTablero(5));

        jButton7.setText(getpiedrasTablero(6));

        jButton8.setText(getpiedrasTablero(7));

        jButton9.setText(getpiedrasTablero(8));

        jButton10.setText(getpiedrasTablero(9));

        jButton11.setText(getpiedrasTablero(10));

        jButton12.setText(getpiedrasTablero(11));

        jButton13.setText(getpiedrasTablero(12));

        jButton14.setText(getpiedrasTablero(13));

    	}
    }
    // refresca el texto en los botones.Se usa despues de cada movimiento valido para mostrar la situacion 
    // actual del tablero
    public void refresh()
    {
    	TextoBotones();
    }
    
    // Comienza el juego
    
    public void openGame()
    {
    	refresh();
    	if (game.HOYOS==5){
    		
    		jButton1.setLocation(750,100);
    		jButton2.setLocation(600,100);
    		jButton3.setLocation(450,100);
    		jButton4.setLocation(300,100);
    		jButton5.setLocation(150,100);
    		jButton8.setLocation(150,250);
    		jButton9.setLocation(300,250);
    		jButton10.setLocation(450,250);
    		jButton11.setLocation(600,250);
    		jButton12.setLocation(750,250);
    		
    		jButton1.addMouseListener(new ButtonClick()
            {
              	public void mouseClicked(MouseEvent e)
      			{
              		
                  		
                  		   game.entradahoyoeleccion("0");
                  		
          			
      			}
      			
             }
         );
       jButton2.addMouseListener(new ButtonClick()
            {
      	 public void mouseClicked(MouseEvent e)
			{
       		
       		   game.entradahoyoeleccion("1");
       		
			}
      			
             }
         );
        jButton3.addMouseListener(new ButtonClick()
              {
              	public void mouseClicked(MouseEvent e)
      			{
              		
              		   game.entradahoyoeleccion("2");
              		
      			}
      			
              }
          );
         jButton4.addMouseListener(new ButtonClick()
         {
      	   public void mouseClicked(MouseEvent e)
 			{
         		
         		   game.entradahoyoeleccion("3");
         		
 			}
 			}
      			
              
              );
              jButton5.addMouseListener(new ButtonClick()
              {
              	public void mouseClicked(MouseEvent e)
      			{
              		
              		   game.entradahoyoeleccion("4");
              		
      			}
      			
              }
              );
              jButton8.addMouseListener(new ButtonClick()
              {
              	public void mouseClicked(MouseEvent e)
      			{
              		
              		   game.entradahoyoeleccion("6");
              		
      			}
      			
              }
              );
              jButton9.addMouseListener(new ButtonClick()
              {
              	public void mouseClicked(MouseEvent e)
      			{
              		
              		   game.entradahoyoeleccion("7");
              		
      			}
      			
              }
              );
              jButton10.addMouseListener(new ButtonClick()
              {
              	public void mouseClicked(MouseEvent e)
      			{
              		
              		   game.entradahoyoeleccion("8");
              		
      			}
      			
              }
              );
              jButton11.addMouseListener(new ButtonClick()
              {
              	public void mouseClicked(MouseEvent e)
      			{
              		
              		   game.entradahoyoeleccion("9");
              		
      			}
      			
              }
              );
              jButton12.addMouseListener(new ButtonClick()
              {
              	public void mouseClicked(MouseEvent e)
      			{
              		
              		   game.entradahoyoeleccion("10");
              		
      			}
      			
              }
              );
    		
        	jButton1.setVisible(true);
        	jButton2.setVisible(true);
        	jButton3.setVisible(true);
        	jButton4.setVisible(true);
        	jButton5.setVisible(true);
        	jButton6.setVisible(false);
        	jButton7.setVisible(true);
        	jButton8.setVisible(true);
        	jButton9.setVisible(true);
        	jButton10.setVisible(true);
        	jButton11.setVisible(true);
        	jButton12.setVisible(true);
        	jButton13.setVisible(false);
        	jButton14.setVisible(true);

    	}else{
    	jButton1.setVisible(true);
    	jButton2.setVisible(true);
    	jButton3.setVisible(true);
    	jButton4.setVisible(true);
    	jButton5.setVisible(true);
    	jButton6.setVisible(true);
    	jButton7.setVisible(true);
    	jButton8.setVisible(true);
    	jButton9.setVisible(true);
    	jButton10.setVisible(true);
    	jButton11.setVisible(true);
    	jButton12.setVisible(true);
    	jButton13.setVisible(true);
    	jButton14.setVisible(true);
	
    	}
    }
    
 // Muestra los botones para la eleccion de partida humano vs maquina, o maquina vs maquina
    
    public void openHumanoDialog()
    {
    	/*jButton25.setFont(new java.awt.Font("Calibri", 10, 40));
    	jButton25.setForeground(Color.yellow);
    	jButton26.setFont(new java.awt.Font("Calibri", 10, 40));
    	jButton26.setForeground(Color.black);
    	jButton25.setText("Humano vs Maquina");
    	jButton26.setText("Maquina vs Maquina");*/
    	jButton25.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/jucp.png")));
    	jButton26.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/cpcp.png")));
    	jButton25.setVisible(true);
		jButton26.setVisible(true);

		
    }
    
    // Muestra los botones para la eleccion del numero de piedras en hoyos
      
    public void openPiedrasDialog()
    {
    	
    	//jButton21.setText("6 PIEDRAS 6 HOYOS");
    	jButton21.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/6x6.png")));
    	//jButton22.setText("5 PIEDRAS 6 HOYOS");
    	jButton22.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/6x5.png")));
    	//jButton23.setText("4 PIEDRAS 6 HOYOS");
    	jButton23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/6x4.png")));
    	//jButton24.setText("3 PIEDRAS 6 HOYOS");
    	jButton24.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/6x3.png")));
    	//jButton27.setText("6 PIEDRAS 5 HOYOS");
    	jButton27.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/5x6.png")));
    	//jButton28.setText("5 PIEDRAS 5 HOYOS");
    	jButton28.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/5x5.png")));
    	//jButton29.setText("4 PIEDRAS 5 HOYOS");
    	jButton29.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/5x4.png")));
    	//jButton30.setText("3 PIEDRAS 5 HOYOS");
    	jButton30.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/5x3.png")));
    	jButton21.setVisible(true);
		jButton22.setVisible(true);
		jButton23.setVisible(true);
		jButton24.setVisible(true);
    	jButton27.setVisible(true);
		jButton28.setVisible(true);
		jButton29.setVisible(true);
		jButton30.setVisible(true);
		
    }
    
    // Muestra los botones para la eleccion de dificultad

    public void opennivelDialog()
    {
    	
    	/*jButton15.setText("FACIL");
    	jButton15.setFont(new java.awt.Font("Calibri", 10, 40));
    	jButton15.setForeground(Color.yellow);
    	jButton16.setText("MEDIO");
    	jButton16.setFont(new java.awt.Font("Calibri", 10, 40));
    	jButton16.setForeground(Color.yellow);
    	jButton17.setText("DIFICIL");
    	jButton17.setFont(new java.awt.Font("Calibri", 10, 40));
    	jButton17.setForeground(Color.yellow);*/
    	jButton15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/fa.png")));
    	jButton16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/med.png")));
    	jButton17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/di.png")));
    	jButton15.setOpaque(false);
    	jButton16.setOpaque(false);
    	jButton17.setOpaque(false);
    	jButton15.setVisible(true);
		jButton16.setVisible(true);
		jButton17.setVisible(true);
    }
  // Muestra los botones para la eleccion de quien empieza la partida
    public void openeleccionDialog()
    {
    	
    	/*jButton18.setText("SI");
    	jButton18.setFont(new java.awt.Font("Calibri", 10, 40));
    	jButton18.setForeground(Color.yellow);
    	jButton19.setText("NO");
    	jButton19.setFont(new java.awt.Font("Calibri", 10, 40));
    	jButton19.setForeground(Color.yellow);*/
    	jButton18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/si.png")));
    	jButton19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/no.png")));
    	jButton18.setOpaque(false);
    	jButton19.setOpaque(false);
    	jButton18.setVisible(true);	
		jButton19.setVisible(true);
    }
    
        
  
    // Oculta los botones usados en las elecciones y la conexion, asi como el campo de texto
    public void closeeleccionDialog()
    {
    	jButton15.setVisible(false);
		jButton16.setVisible(false);
		jButton17.setVisible(false);
		jButton18.setVisible(false);
		jButton19.setVisible(false);
		jButton20.setVisible(false);
		jButton21.setVisible(false);
		jButton22.setVisible(false);
		jButton23.setVisible(false);
		jButton24.setVisible(false);
		jButton25.setVisible(false);
		jButton26.setVisible(false);		
		jButton27.setVisible(false);
		jButton28.setVisible(false);
		jButton29.setVisible(false);
		jButton30.setVisible(false);
		
		entrada.setVisible(false);
		
    }
    
    
 
    private JButton jButton1;
    private JButton jButton10;
    private JButton jButton11;
    private JButton jButton12;
    private JButton jButton13;
    private JButton jButton14;
    private JButton jButton15;
    private JButton jButton16;
    private JButton jButton17;
    private JButton jButton18;
    private JButton jButton19;
    private JButton jButton2;
    private JButton jButton20;
    private JButton jButton21;
    private JButton jButton22;
    private JButton jButton23;
    private JButton jButton24;
    private JButton jButton25;
    private JButton jButton26;
    private JButton jButton27;
    private JButton jButton28;
    private JButton jButton29;
    private JButton jButton3;
    private JButton jButton30;
    private JButton jButton4;
    private JButton jButton5;
    private JButton jButton6;
    private JButton jButton7;
    private JButton jButton8;
    private JButton jButton9;
    private JFrame jFrame1;
    private JScrollPane jScrollPane1;
    public  JTextArea jTextArea1;
    private JTextField entrada,entrada2;
    Kalaha game ;
 // Fin de declaracion de variables   
    
    
 //clases para eventos de raton
    
    class ButtonClick implements MouseListener
	{

		public void mouseClicked(MouseEvent e){}

		public void mouseEntered(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}

		public void mouseExited(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}

		public void mousePressed(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}

		public void mouseReleased(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}
		
	}
	
    
}
