sábado, 14 de septiembre de 2013

obtener un valor de una bd

ResultSet resultados = s.executeQuery(""); resultados.next(); a = resultados.getObject("nombre").toString();

sábado, 7 de septiembre de 2013

ingresar un nuevo usuario en java y usando una conexion existente a una bd

conector c = new conector();


Statement s = c.mysql().createStatement();
         
s.execute("INSERT INTO afiliado (cc, login,pasword)VALUES (64554, 'kira','kira') ");

viernes, 6 de septiembre de 2013

drop down list y bases de datos


esto retorna una lista de los valores del select dentro de un dropdown list html


<select name="dropdown">
                        <sql:query var="result" dataSource="clubBD">
                             SELECT nombre FROM canchas
                        </sql:query>
                         <c:forEach var="row" items="${result.rowsByIndex}">
                            <c:forEach var="column" items="${row}">
                                <option><c:out value="${column}"/></option>
                            </c:forEach>
       
                        </c:forEach>
                    </select>

jueves, 5 de septiembre de 2013

BATALLA NAVAL 1 EN JAVA POR PAULO ESCOBAR


aca en esta impresion de pantalla vemos las clases del juego.

ACA PODEMOS VER LAS CLASES ABSTRACTAS

public abstract class Barco
 {
      public abstract void posicionarBarcoV(int[][] matrizJugador, int fila, int columna,javax.swing.JLabel a);

public abstract void posicionarBarcoH(int[][] matrizJugador, int fila, int columna,javax.swing.JLabel a);
    public abstract void resetContador();
    
}
____________________________________________________________________

public abstract class Jugadores  {
    public abstract void atacar(int[][] jugador2,int filas, int columnas,JLabel j);
    public abstract void crearJugador(int[][] jugador2);
    
}


CLASE JUGADOR 1


public class Jugador1 extends Jugadores{


    public static int c2,c3,c4,c5;
    public static int contador=1;
    public static String Nombre = "paulo y el mono ";
    public static int contadordePuntosAcertados =0;
     @Override
     /**recive como parametro la matriz del jugador al que se atacara
      y las filas y las columnas donde se genero la accion ademas el jlabel que esta
      en esa posicion para cambiarlo*/
    public void atacar(int[][] jugador2, int filas, int columnas, JLabel j)
     {
         j.setBackground(Color.gray);
         int clave=0, posicionesdeunbarco=0;
     
         /*este primer if verifica que se de en cualquier blanco*/
        if(jugador2[filas][columnas]!=0)
        {
            JOptionPane.showMessageDialog(null, Nombre+"¡¡ han dado en el blanco!!");
            contadordePuntosAcertados ++;
            j.setBackground(Color.orange);
            j.setText(""+jugador2[filas][columnas]);
         
            if (jugador2[filas][columnas]==2)
            {
                clave=20;
                posicionesdeunbarco =2;
                jugador2[filas][columnas]=clave;
            }
            if (jugador2[filas][columnas]==3)
            {
                clave=30;
                posicionesdeunbarco =3;
                jugador2[filas][columnas]=clave;
             
            }
             
             if (jugador2[filas][columnas]==4)
            {
                clave=40;
                posicionesdeunbarco =4;
                jugador2[filas][columnas]=clave;
             
            }
            if (jugador2[filas][columnas]==5)
            {
                clave=50;
                posicionesdeunbarco =5;
                jugador2[filas][columnas]=clave;
             
            }
            if (contadordePuntosAcertados>24)
            {
                JOptionPane.showMessageDialog(null,Nombre+"Han dado de baja al oponente");
            }
       }
     }

    @Override
    public void crearJugador(int[][] jugador2) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
_____


BATALLA NAVAL EN JAVA JFRAMES Y JUGADOR CPU


CLASE JUGADOR CPU


public class Jugador1 extends Jugadores{
    public static int c2,c3,c4,c5;
    public static int contador=1;
    public static String Nombre = "paulo y el mono ";
    public static int contadordePuntosAcertados =0;
     @Override
     /**recive como parametro la matriz del jugador al que se atacara
      y las filas y las columnas donde se genero la accion ademas el jlabel que esta
      en esa posicion para cambiarlo*/
    public void atacar(int[][] jugador2, int filas, int columnas, JLabel j)
     {
         j.setBackground(Color.gray);
         int clave=0, posicionesdeunbarco=0;
       
         /*este primer if verifica que se de en cualquier blanco*/
        if(jugador2[filas][columnas]!=0)
        {
            JOptionPane.showMessageDialog(null, Nombre+"¡¡ han dado en el blanco!!");
            contadordePuntosAcertados ++;
            j.setBackground(Color.orange);
            j.setText(""+jugador2[filas][columnas]);
         
            if (jugador2[filas][columnas]==2)
            {
                clave=20;
                posicionesdeunbarco =2;
                jugador2[filas][columnas]=clave;
            }
            if (jugador2[filas][columnas]==3)
            {
                clave=30;
                posicionesdeunbarco =3;
                jugador2[filas][columnas]=clave;
             
            }
             
             if (jugador2[filas][columnas]==4)
            {
                clave=40;
                posicionesdeunbarco =4;
                jugador2[filas][columnas]=clave;
             
            }
            if (jugador2[filas][columnas]==5)
            {
                clave=50;
                posicionesdeunbarco =5;
                jugador2[filas][columnas]=clave;
             
            }
            if (contadordePuntosAcertados>24)
            {
                JOptionPane.showMessageDialog(null,Nombre+"Han dado de baja al oponente");
            }
         

        }

     
     }
 


    @Override
    public void crearJugador(int[][] jugador2) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
______________________________________________________________
AHORA CREAREMOS LA PARTE VISUAL
IMPORTAMOS PRIMERO DOS JFRAMES CON  UN ENTORNO GRAFICO ASI



LA PRIMERA SE VA A LLAMAR BATALLA NAVAL COMIENZO

Jugadores player1 = new Jugador1();
Jugadores player2 = new Jugador_CPU();
Random r = new Random();

boolean swiche = true;
boolean DatoRepetido=false;
RecividorDatos[] posicionesyatomadas = new RecividorDatos[100];

JLabel vv = new JLabel();
int contador=0;
RecividorDatos dato;
int auxiliar=0;
int x,y;
    public void ataqueJugador2()
    {
        x = (int)(r.nextDouble() * 10+ 1);            
        y = (int)(r.nextDouble() * 10+ 1);
        dato = new RecividorDatos(x, y);
        dato.x=x;
        dato.y=y;
        posicionesyatomadas[auxiliar] = dato;
//        while(Campo_de_Batalla.player1[x][y]!=0||DatoRepetido
  //      ||Campo_de_Batalla.player1[x][y]!=2||Campo_de_Batalla.player1[x][y]!=3||Campo_de_Batalla.player1[x][y]!=4||Campo_de_Batalla.player1[x][y]!=5)
//        {
//           
//             dato.x = (int)(r.nextDouble() * 11+ 1);
//             dato.y = (int)(r.nextDouble() * 11+ 1);
            for(int i =0;i<100;i++)
            {
                if (posicionesyatomadas[i]!=null)
                {
                    if (dato.x ==posicionesyatomadas[i].x)
                    {
                        dato.x = (int)(r.nextDouble() * 10+ 1);
                        x= dato.x;
                        DatoRepetido=true;
                    }
                    if (dato.x ==posicionesyatomadas[i].x)
                    {
                        dato.y = (int)(r.nextDouble() * 10+ 1);
                        DatoRepetido=true;
                    }

                    else
                    {
                        DatoRepetido=false;
                        x= dato.x;
                        y= dato.y;
                        posicionesyatomadas[auxiliar] = dato;
                    }
                }
                    
//            }
            
        }
        auxiliar++;
        
            player2.atacar(Campo_de_Batalla.player1,x, y, vv);
            System.out.println("ud fue atacado en la posicion filas = "+x+" columnas: "+y);
            x = (int)(r.nextDouble() * 11+ 1);            
            y = (int)(r.nextDouble() * 11+ 1);
            
    }
///////posiciones de fila 1//////////////////////////////////////////////
 boolean espres=false;
    private void cpu11MouseClicked(java.awt.event.MouseEvent evt) {                                   
       
//posicion (1,1)
    if (!espres){ 
        player1.atacar(Campo_de_Batalla.Player2, 1, 1, cpu11);
        ataqueJugador2();
        espres=true;

      }
    }                                  
 boolean press=false;
    private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {                                     
//       
      if (!press)
      {
            player1.atacar(Campo_de_Batalla.Player2, 1, 2,jLabel2);
            ataqueJugador2();
            press=true;
        }
    }                                    
boolean fup=false;
    private void jLabel5MouseClicked(java.awt.event.MouseEvent evt) {                                     
        
       if (!fup)
       {
            player1.atacar(Campo_de_Batalla.Player2, 1, 3,jLabel5);
            ataqueJugador2();

           fup=true;
        
       }
    }                                    
boolean furepre=false;
    private void jLabel4MouseClicked(java.awt.event.MouseEvent evt) {                                     
        
        // TODO add your handling code here:
        if (!furepre)
        {
       player1.atacar(Campo_de_Batalla.Player2, 1, 4,jLabel4);
       ataqueJugador2();

        furepre = true;
        }
    }                                    
boolean fuepre =false;
    private void jLabel7MouseClicked(java.awt.event.MouseEvent evt) {                                     
        if (!fuepre)
        {
           player1.atacar(Campo_de_Batalla.Player2, 1, 5,jLabel7);
            ataqueJugador2();
           

            fuepre=true;
        }
    }                                    
boolean fuePresionadojLabel6=false;
    private void jLabel6MouseClicked(java.awt.event.MouseEvent evt) {                                     
        
        if (!fuePresionadojLabel6)
        {
         player1.atacar(Campo_de_Batalla.Player2, 1, 6,jLabel6); 
        ataqueJugador2();

           fuePresionadojLabel6=true;
        }
    }                                    
 boolean nopresion=false;
    private void jLabel9MouseClicked(java.awt.event.MouseEvent evt) {                                     

        if (!nopresion)
        {
           player1.atacar(Campo_de_Batalla.Player2, 1, 7,jLabel9);
        ataqueJugador2();

            nopresion= true;
        }
        
    }                                    
boolean nopresiona2= false;
    private void jLabel8MouseClicked(java.awt.event.MouseEvent evt) {                                     
        
     if (!nopresiona2)
        {
           player1.atacar(Campo_de_Batalla.Player2, 1, 8,jLabel8);
        ataqueJugador2();

            nopresiona2= true;
        }
        
    
    }                                    
     
    boolean presiona21=false;

    private void A19MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!presiona21)
        {
            player1.atacar(Campo_de_Batalla.Player2, 1, 9,A19);
           ataqueJugador2();
            presiona21=true;
        } 
    
    }                                
  boolean pA110=false;
    private void A110MouseClicked(java.awt.event.MouseEvent evt) {                                  
            if (!pA110){
            player1.atacar(Campo_de_Batalla.Player2, 1, 10,A110);
            ataqueJugador2();
            pA110=true;
            }
            
    }                                 
boolean pressB21=false;
    private void B21MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
       if (!pressB21)
       { 
           player1.atacar(Campo_de_Batalla.Player2, 2, 1,B21);
           ataqueJugador2();
            pressB21=true;
            
       }
            

    }                                
boolean pressB22= false;
    private void B22MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
       if (!pressB22){
        
            player1.atacar(Campo_de_Batalla.Player2, 2, 2,B22);
            ataqueJugador2();
            pressB22= true;
       }
        
    }                                
boolean pc41=false;
    private void C41MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
        if (!pc41)
        {
            player1.atacar(Campo_de_Batalla.Player2, 4, 1,C41);
            ataqueJugador2();
            pc41= true;
       }    
    }                                
boolean pB23=false;
    private void B23MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pB23){
        
            player1.atacar(Campo_de_Batalla.Player2, 2, 3,B23);
            ataqueJugador2();
            pB23= true;
       }         
    }                                
boolean pB24=false;
    private void B24MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pB24){
        
            player1.atacar(Campo_de_Batalla.Player2, 2, 4,B24);
            ataqueJugador2();
            pB24= true;
       }   
    }                                
boolean pB25=false;
    private void B25MouseClicked(java.awt.event.MouseEvent evt) {                                 
         if (!pB25){
        
            player1.atacar(Campo_de_Batalla.Player2, 2, 5,B25);
            ataqueJugador2();
            pB25= true;
       }   
    }                                
boolean pB26=false;

    private void B26MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pB26)
        {
            player1.atacar(Campo_de_Batalla.Player2, 2, 6,B26);
            ataqueJugador2();
            pB26= true;
       }  
    }                                
boolean pB27=false;
    private void B27MouseClicked(java.awt.event.MouseEvent evt) {                                 

       if (!pB27)
        {
            player1.atacar(Campo_de_Batalla.Player2, 2, 7,B27);
            ataqueJugador2();
            pB27= true;
       }  
    }                                
boolean pB28=false;

    private void B28MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pB28)
        {
            player1.atacar(Campo_de_Batalla.Player2, 2, 8,B28);
            ataqueJugador2();
            pB28= true;
       }          
    }                                
boolean pB29=false;

    private void Bb29MouseClicked(java.awt.event.MouseEvent evt) {                                  
        if (!pB29)
        {
            player1.atacar(Campo_de_Batalla.Player2, 2, 8,Bb29);
            ataqueJugador2();
            pB29= true;
       }          
           
    }                                 


    boolean pB210=false;

    private void B210MouseClicked(java.awt.event.MouseEvent evt) {                                  
         if (!pB210)
        {
            player1.atacar(Campo_de_Batalla.Player2, 2, 10,B210);
            ataqueJugador2();
            pB210= true;
       } 
    }                                 
boolean pc31=false;
    private void C31MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc31)
        {
            player1.atacar(Campo_de_Batalla.Player2, 3, 1,C31);
            ataqueJugador2();
            pc31= true;
       } 
    }                                
boolean pc32=false;
    private void C32MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
        if (!pc32)
        {
            player1.atacar(Campo_de_Batalla.Player2, 3, 2,C32);
            ataqueJugador2();
            pc32= true;
       }         
    }                                
 boolean pc33=false;       
    private void C33MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
        if (!pc33)
        {
            player1.atacar(Campo_de_Batalla.Player2, 3, 3,C33);
            ataqueJugador2();
            pc33= true;
       }            
    }                                
boolean pc34=false;
    private void C34MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
        if (!pc34)
        {
            player1.atacar(Campo_de_Batalla.Player2, 3, 4,C34);
            ataqueJugador2();
            pc34= true;
       }            // TODO add your handling code here:
    }                                
boolean pc35=false;
    private void C35MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
        if (!pc35)
        {
            player1.atacar(Campo_de_Batalla.Player2, 3, 5,C35);
            ataqueJugador2();
            pc35= true;
       }            // TODO add your handling code here:
    }                                
boolean pc36=false;
    private void C36MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
        if (!pc36)
        {
            player1.atacar(Campo_de_Batalla.Player2, 3, 6,C36);
            ataqueJugador2();
            pc36= true;
       }            
    }                                
boolean pc37=false;
    private void C37MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
        if (!pc37)
        {
            player1.atacar(Campo_de_Batalla.Player2, 3, 7,C37);
            ataqueJugador2();
            pc37= true;
       }           
    }                                
boolean pc38=false;
    private void C38MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
        if (!pc38)
        {
            player1.atacar(Campo_de_Batalla.Player2, 3, 8,C38);
            ataqueJugador2();
            pc38= true;
       }   
    }                                
boolean pc39=false;
    private void C39MouseClicked(java.awt.event.MouseEvent evt) {                                 
        
        if (!pc39)
        {
            player1.atacar(Campo_de_Batalla.Player2, 3, 9,C39);
            ataqueJugador2();
            pc39= true;
       }          
    }                                
boolean pc310=false;
    private void C310MouseClicked(java.awt.event.MouseEvent evt) {                                  
        
        if (!pc310)
        {
            player1.atacar(Campo_de_Batalla.Player2, 3, 10,C310);
            ataqueJugador2();
            pc310= true;
       }            
    }                                 
boolean pc42=false;
    private void C42MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc42)
        {
            player1.atacar(Campo_de_Batalla.Player2, 4, 2,C42);
            ataqueJugador2();
            pc42= true;
       }            // TODO add your handling code here:
    }                                
boolean pc43=false;
    private void C43MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc43)
        {
            player1.atacar(Campo_de_Batalla.Player2, 4, 3,C43);
            ataqueJugador2();
            pc43= true;
       }            // TODO add your handling code here:
    }                                
boolean pc44=false;
    private void C44MouseClicked(java.awt.event.MouseEvent evt) {                                 
       
        if (!pc44)
        {
            player1.atacar(Campo_de_Batalla.Player2, 4, 4,C44);
            ataqueJugador2();
            pc44= true;
       }    
    }                                
boolean pc45=false;
    private void C45MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc45)
        {
            player1.atacar(Campo_de_Batalla.Player2, 4, 5,C45);
            ataqueJugador2();
            pc45= true;
       }            // TODO add your handling code here:
    }                                
boolean pc46=false;
    private void C46MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc46)
        {
            player1.atacar(Campo_de_Batalla.Player2, 4, 6,C46);
            ataqueJugador2();
            pc46= true;
       }         
    }                                
boolean pc47=false;
    private void C47MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc47)
        {
            player1.atacar(Campo_de_Batalla.Player2, 4, 7,C47);
            ataqueJugador2();
            pc47= true;
       }            // TODO add your handling code here:
    }                                
boolean pc48=false;
    private void C48MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc48)
        {
            player1.atacar(Campo_de_Batalla.Player2, 4, 8,C48);
            ataqueJugador2();
            pc48= true;
       }            // TODO add your handling code here:
    }                                
boolean pc49=false;

    private void C49MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pc49)
        {
            player1.atacar(Campo_de_Batalla.Player2, 4, 9,C49);
            ataqueJugador2();
            pc49= true;
       }            // TODO add your handling code here:
    }                                
boolean pc410=false;
    private void C410MouseClicked(java.awt.event.MouseEvent evt) {                                  

        if (!pc410)
        {
            player1.atacar(Campo_de_Batalla.Player2, 4, 10,C410);
            ataqueJugador2();
            pc410= true;
       }            // TODO add your handling code here:
    }                                 
boolean pc51=false;
    private void C51MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pc51)
        {
            player1.atacar(Campo_de_Batalla.Player2, 5, 1,C51);
            ataqueJugador2();
            pc51= true;
       }            // TODO add your handling code here:
    }                                
boolean pc52=false;
    private void C52MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc52)
        {
            player1.atacar(Campo_de_Batalla.Player2, 5, 2,C52);
            ataqueJugador2();
            pc52= true;
       }            // TODO add your handling code here:
    }                                
boolean pc53=false;
    private void C53MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc53)
        {
            player1.atacar(Campo_de_Batalla.Player2, 5, 3,C53);
            ataqueJugador2();
            pc53= true;
       }            // TODO add your handling code here:
    }                                
boolean pc54=false;
    private void C54MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc54)
        {
            player1.atacar(Campo_de_Batalla.Player2, 5, 4,C54);
            ataqueJugador2();
            pc54= true;
       }            // TODO add your handling code here:
    }                                
boolean pc55=false;
    private void C55MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc55)
        {
            player1.atacar(Campo_de_Batalla.Player2, 5, 5,C55);
            ataqueJugador2();
            pc55= true;
       }            // TODO add your handling code here:
    }                                
boolean pc56=false;
    private void C56MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc56)
        {
            player1.atacar(Campo_de_Batalla.Player2, 5, 6,C56);
            ataqueJugador2();
            pc56= true;
       }            // TODO add your handling code here:
    }                                
boolean pc57=false;
    private void C57MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc57)
        {
            player1.atacar(Campo_de_Batalla.Player2, 5, 7,C57);
            ataqueJugador2();
            pc57= true;
       }            // TODO add your handling code here:
    }                                
boolean pc58=false;
    private void C58MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc58)
        {
            player1.atacar(Campo_de_Batalla.Player2, 5, 8,C58);
            ataqueJugador2();
            pc58= true;
       }            // TODO add your handling code here:
    }                                
boolean pc59=false;
    private void C59MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc59)
        {
            player1.atacar(Campo_de_Batalla.Player2, 5, 1,C59);
            ataqueJugador2();
            pc59= true;
       }            // TODO add your handling code here:
    }                                
boolean pc510=false;
    private void C510MouseClicked(java.awt.event.MouseEvent evt) {                                  

        if (!pc510)
        {
            player1.atacar(Campo_de_Batalla.Player2, 5, 10,C510);
            ataqueJugador2();
            pc510= true;
       }            // TODO add your handling code here:
    }                                 
boolean pc61=false;
    private void C61MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc61)
        {
            player1.atacar(Campo_de_Batalla.Player2, 6, 1,C61);
            ataqueJugador2();
            pc61= true;
       }            // TODO add your handling code here:
    }                                
boolean pc62=false;
    private void C62MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc62)
        {
            player1.atacar(Campo_de_Batalla.Player2, 6, 2,C62);
            ataqueJugador2();
            pc62= true;
       }             // TODO add your handling code here:
    }                                
boolean pc63=false;
    private void C63MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc63)
        {
            player1.atacar(Campo_de_Batalla.Player2, 6, 3,C63);
            ataqueJugador2();
            pc63= true;
       }             // TODO add your handling code here:
    }                                
boolean pc64=false;
    private void C64MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc64)
        {
            player1.atacar(Campo_de_Batalla.Player2, 6, 4,C64);
            ataqueJugador2();
            pc64= true;
       }             // TODO add your handling code here:
    }                                
boolean pc65=false;
    private void C65MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc65)
        {
            player1.atacar(Campo_de_Batalla.Player2, 6, 5,C65);
            ataqueJugador2();
            pc65= true;
       }             // TODO add your handling code here:
    }                                
boolean pc66=false;
    private void C66MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc66)
        {
            player1.atacar(Campo_de_Batalla.Player2, 6, 6,C66);
            ataqueJugador2();
            pc66= true;
       }             // TODO add your handling code here:
    }                                
boolean pc67=false;
    private void C67MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc67)
        {
            player1.atacar(Campo_de_Batalla.Player2, 6, 7,C67);
            ataqueJugador2();
            pc67= true;
       }             // TODO add your handling code here:
    }                                
boolean pc68=false;
    private void C68MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc68)
        {
            player1.atacar(Campo_de_Batalla.Player2, 6, 8,C68);
            ataqueJugador2();
            pc68= true;
       }             // TODO add your handling code here:
    }                                
boolean pc69=false;
    private void C69MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc69)
        {
            player1.atacar(Campo_de_Batalla.Player2, 6, 9,C69);
            ataqueJugador2();
            pc69= true;
       }             // TODO add your handling code here:
    }                                
boolean pc610=false;
    private void C610MouseClicked(java.awt.event.MouseEvent evt) {                                  

        if (!pc610)
        {
            player1.atacar(Campo_de_Batalla.Player2, 6, 10,C610);
            ataqueJugador2();
            pc610= true;
       }             // TODO add your handling code here:
    }                                 
boolean pc71=false;
    private void C71MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc71)
        {
            player1.atacar(Campo_de_Batalla.Player2, 7, 1,C71);
            ataqueJugador2();
            pc71= true;
       }             // TODO add your handling code here:
    }                                
boolean pc72=false;
    private void C72MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc72)
        {
            player1.atacar(Campo_de_Batalla.Player2, 7, 2,C72);
            ataqueJugador2();
            pc72= true;
       }          // TODO add your handling code here:
    }                                
boolean pc73=false;
    private void C73MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc73)
        {
            player1.atacar(Campo_de_Batalla.Player2, 7, 3,C73);
            ataqueJugador2();
            pc73= true;
       }          // TODO add your handling code here:
    }                                

    private void C74MouseEntered(java.awt.event.MouseEvent evt) {                                 
         // TODO add your handling code here:
    }                                
boolean pc74=false;
    private void C74MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc74)
        {
            player1.atacar(Campo_de_Batalla.Player2, 7, 4,C74);
            ataqueJugador2();
            pc74= true;
       }          // TODO add your handling code here:
    }                                
boolean pc75=false;
    private void C75MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc75)
        {
            player1.atacar(Campo_de_Batalla.Player2, 7, 5,C75);
            ataqueJugador2();
            pc75= true;
       }          // TODO add your handling code here:
    }                                
boolean pc76=false;
    private void C76MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc76)
        {
            player1.atacar(Campo_de_Batalla.Player2, 7, 6,C76);
            ataqueJugador2();
            pc76= true;
       }          // TODO add your handling code here:
    }                                
boolean pc77=false;
    private void C77MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc77)
        {
            player1.atacar(Campo_de_Batalla.Player2, 7, 7,C77);
            ataqueJugador2();
            pc77= true;
       }          // TODO add your handling code here:
    }                                
boolean pc78=false;
    private void C78MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc78)
        {
            player1.atacar(Campo_de_Batalla.Player2, 7,8,C78);
            ataqueJugador2();
            pc78= true;
       }          // TODO add your handling code here:
    }                                
boolean pc79=false;
    private void C79MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc79)
        {
            player1.atacar(Campo_de_Batalla.Player2, 7, 9,C79);
            ataqueJugador2();
            pc79= true;
       }          // TODO add your handling code here:
    }                                
boolean pc710=false;
    private void C710MouseClicked(java.awt.event.MouseEvent evt) {                                  

        if (!pc710)
        {
            player1.atacar(Campo_de_Batalla.Player2, 7, 10,C710);
            ataqueJugador2();
            pc710= true;
       }          // TODO add your handling code here:
    }                                 
boolean pc81=false;
    private void C81MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc81)
        {
            player1.atacar(Campo_de_Batalla.Player2, 8, 1,C81);
            ataqueJugador2();
            pc81= true;
       }          // TODO add your handling code here:
    }                                
boolean pc82=false;
    private void C82MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc82)
        {
            player1.atacar(Campo_de_Batalla.Player2, 8, 2,C82);
            ataqueJugador2();
            pc82= true;
       }         // TODO add your handling code here:
    }                                
boolean pc83=false;
    private void C83MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc83)
        {
            player1.atacar(Campo_de_Batalla.Player2, 8, 3,C83);
            ataqueJugador2();
            pc83= true;
       }         // TODO add your handling code here:
    }                                
boolean pc84=false;

    private void C84MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pc84)
        {
            player1.atacar(Campo_de_Batalla.Player2, 8, 1,C84);
            ataqueJugador2();
            pc84= true;
       }         // TODO add your handling code here:
    }                                
boolean pc85=false;
    private void C85MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc85)
        {
            player1.atacar(Campo_de_Batalla.Player2, 8, 5,C85);
            ataqueJugador2();
            pc85= true;
       }         // TODO add your handling code here:
    }                                
boolean pc86=false;

    private void C86MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pc86)
        {
            player1.atacar(Campo_de_Batalla.Player2, 8, 6,C86);
            ataqueJugador2();
            pc86= true;
       }         // TODO add your handling code here:
    }                                
boolean pc87=false;

    private void C87MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pc87)
        {
            player1.atacar(Campo_de_Batalla.Player2, 8, 7,C87);
            ataqueJugador2();
            pc87= true;
       }         // TODO add your handling code here:
    }                                
boolean pc88=false;
    private void C88MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc88)
        {
            player1.atacar(Campo_de_Batalla.Player2, 8, 8,C88);
            ataqueJugador2();
            pc88= true;
       }         // TODO add your handling code here:
    }                                
boolean pc89=false;
    private void C89MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc89)
        {
            player1.atacar(Campo_de_Batalla.Player2, 8, 9,C89);
            ataqueJugador2();
            pc89= true;
       }         // TODO add your handling code here:
    }                                
boolean pc810=false;
    private void C810MouseClicked(java.awt.event.MouseEvent evt) {                                  

        if (!pc810)
        {
            player1.atacar(Campo_de_Batalla.Player2, 8, 10,C810);
            ataqueJugador2();
            pc810= true;
       }         // TODO add your handling code here:
    }                                 
boolean pc91=false;
    private void C91MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc91)
        {
            player1.atacar(Campo_de_Batalla.Player2, 9, 1,C91);
            ataqueJugador2();
            pc91= true;
       }         // TODO add your handling code here:
    }                                
boolean pc92=false;
    private void C92MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc92)
        {
            player1.atacar(Campo_de_Batalla.Player2, 9, 2,C92);
            ataqueJugador2();
            pc92= true;
       }              // TODO add your handling code here:
    }                                
boolean pc93=false;
    private void C93MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pc93)
        {
            player1.atacar(Campo_de_Batalla.Player2, 9, 3,C93);
            ataqueJugador2();
            pc93= true;
       }              // TODO add your handling code here:
    }                                
boolean pc94=false;
    private void C94MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc94)
        {
            player1.atacar(Campo_de_Batalla.Player2, 9, 4,C94);
            ataqueJugador2();
            pc94= true;
       }           // TODO add your handling code here:
    }                                
boolean pc95=false;

    private void C95MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pc95)
        {
            player1.atacar(Campo_de_Batalla.Player2, 9, 5,C95);
            ataqueJugador2();
            pc95= true;
       }           // TODO add your handling code here:
    }                                
boolean pc96=false;
    private void C96MouseClicked(java.awt.event.MouseEvent evt) {                                 

        if (!pc96)
        {
            player1.atacar(Campo_de_Batalla.Player2, 9, 6,C96);
            ataqueJugador2();
            pc96= true;
       }           // TODO add your handling code here:
    }                                
boolean pc97=false;

    private void C97MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pc97)
        {
            player1.atacar(Campo_de_Batalla.Player2, 9, 7,C97);
            ataqueJugador2();
            pc97= true;
       }           // TODO add your handling code here:
    }                                
boolean pc98=false;

    private void C98MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pc98)
        {
            player1.atacar(Campo_de_Batalla.Player2, 9, 8,C98);
            ataqueJugador2();
            pc98= true;
       }           // TODO add your handling code here:
    }                                
boolean pc99=false;

    private void C99MouseClicked(java.awt.event.MouseEvent evt) {                                 
        if (!pc99)
        {
            player1.atacar(Campo_de_Batalla.Player2, 9, 9,C99);
            ataqueJugador2();
            pc99= true;
       }           // TODO add your handling code here:
    }                                
boolean pc910=false;

    private void C910MouseClicked(java.awt.event.MouseEvent evt) {                                  
        if (!pc910)
        {
            player1.atacar(Campo_de_Batalla.Player2, 9, 10,C910);
            ataqueJugador2();
            pc910= true;
       }           // TODO add your handling code here:
    }                                 
boolean pc101=false;
    private void C101MouseClicked(java.awt.event.MouseEvent evt) {                                  

        if (!pc101)
        {
            player1.atacar(Campo_de_Batalla.Player2, 10, 1,C101);
            ataqueJugador2();
            pc101= true;
       }           // TODO add your handling code here:
    }                                 
boolean pc102=false;

    private void C102MouseClicked(java.awt.event.MouseEvent evt) {                                  
        if (!pc102)
        {
            player1.atacar(Campo_de_Batalla.Player2, 10, 2,C102);
            ataqueJugador2();
            pc102= true;
       }           // TODO add your handling code here:
    }                                 
boolean pc103=false;

    private void C103MouseClicked(java.awt.event.MouseEvent evt) {                                  
        if (!pc103)
        {
            player1.atacar(Campo_de_Batalla.Player2, 10, 3,C103);
            ataqueJugador2();
            pc103= true;
       }           // TODO add your handling code here:
    }                                 
boolean pc104=false;
    private void C104MouseClicked(java.awt.event.MouseEvent evt) {                                  

        if (!pc104)
        {
            player1.atacar(Campo_de_Batalla.Player2, 10, 4,C104);
            ataqueJugador2();
            pc104= true;
       }           // TODO add your handling code here:
    }                                 
boolean pc105=false;

    private void C105MouseClicked(java.awt.event.MouseEvent evt) {                                  
        if (!pc105)
        {
            player1.atacar(Campo_de_Batalla.Player2, 10, 5,C105);
            ataqueJugador2();
            pc105= true;
       }           // TODO add your handling code here:
    }                                 
boolean pc106=false;
    private void C106MouseClicked(java.awt.event.MouseEvent evt) {                                  

        if (!pc106)
        {
            player1.atacar(Campo_de_Batalla.Player2, 10, 6,C106);
            ataqueJugador2();
            pc106= true;
       }           // TODO add your handling code here:
    }                                 
boolean pc107=false;

    private void C107MouseClicked(java.awt.event.MouseEvent evt) {                                  
        if (!pc107)
        {
            player1.atacar(Campo_de_Batalla.Player2, 10, 7,C107);
            ataqueJugador2();
            pc107= true;
       }           // TODO add your handling code here:
    }                                 
boolean pc108=false;

    private void C108MouseClicked(java.awt.event.MouseEvent evt) {                                  
        if (!pc108)
        {
            player1.atacar(Campo_de_Batalla.Player2, 10, 8,C108);
            ataqueJugador2();
            pc108= true;
       }           // TODO add your handling code here:
    }                                 
boolean pc109=false;

    private void C109MouseClicked(java.awt.event.MouseEvent evt) {                                  
        if (!pc109)
        {
            player1.atacar(Campo_de_Batalla.Player2, 10, 9,C109);
            ataqueJugador2();
            pc109= true;
       }           // TODO add your handling code here:
    }                                 
boolean pc1010=false;

    private void C1010MouseClicked(java.awt.event.MouseEvent evt) {                                   
        if (!pc1010)
        {
            player1.atacar(Campo_de_Batalla.Player2, 10, 10,C1010);
            ataqueJugador2();
            pc1010= true;
       }          
    } 
____________________________________________________________________________                                 

EL OTRO JFRAME QUE CREAMOS TIENE EL SIGUIENTE CODIGO

   // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {
                   
Barco b2 =new Barco_2();
Barco b3 =new Barco_3();
Barco b4 =new Barco_4();
Barco b5 =new Barco_5();
Jugadores p1= new Jugador1();
static int[][] player1 =new int[11][11];
static int[][] Player2 = new int [11][11];
public static int[][] Getplayer2()
{
    return Player2;
}
public static int[][] Getplayer1()
{
    return player1;
}


    private void barco5pasajerosHorizontalMouseClicked(java.awt.event.MouseEvent evt) {                                                       
        try
        {
             b5.posicionarBarcoH(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco5pasajerosHorizontal);
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }
    }                                                      

    private void barco4pasajerosVertical2MouseClicked(java.awt.event.MouseEvent evt) {                                                      
       
        try
        {
            b4.posicionarBarcoV(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco4pasajerosVertical2);
        }
        catch( ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }

    }                                                     

    private void barco4pasajerosHorizontalMouseClicked(java.awt.event.MouseEvent evt) {                                                       
       try
       {
            b4.posicionarBarcoH(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco4pasajerosHorizontal);
       }
       catch(ArrayIndexOutOfBoundsException e)
       {
           System.out.println("Error capturado");
       }
    }                                                      

    private void barco2pasajerosHorizontal3MouseClicked(java.awt.event.MouseEvent evt) {                                                        
       
        try
        {
            b2.posicionarBarcoH(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco2pasajerosHorizontal3);
        }        
        catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }
    }                                                       

    private void barco2pasajerosHorizontalMouseClicked(java.awt.event.MouseEvent evt) {                                                       
        try {
            b2.posicionarBarcoH(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco2pasajerosHorizontal);
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }
    }                                                      

    private void barco2pasajerosHorizontal2MouseClicked(java.awt.event.MouseEvent evt) {                                                        

        try{
            b2.posicionarBarcoH(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco2pasajerosHorizontal2);
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }

        //seleccion del barco de dos casillanarcs horizontal
    } 
    private void barco2pasajerosVertical3MouseClicked(java.awt.event.MouseEvent evt) {                                                      
       try{
           b2.posicionarBarcoV(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco2pasajerosVertical3);
       }
       catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }

    }                                                     

    private void barco2pasajerosVertical2MouseClicked(java.awt.event.MouseEvent evt) {                                                      

        try{
            b2.posicionarBarcoV(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco2pasajerosVertical2);
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
           System.out.println("Error capturado"); 
        }


    }                                                     

    private void barco2pasajerosVerticalMouseClicked(java.awt.event.MouseEvent evt) {                                                     
        try{
            b2.posicionarBarcoV(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco2pasajerosVertical);
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }

    }                                                    

    private void barco5pasajerosVerticalMouseClicked(java.awt.event.MouseEvent evt) {                                                     
        try{
            b5.posicionarBarcoV(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco5pasajerosVertical);
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }

    }                                                    

    private void barco3pasajerosHorizontalMouseClicked(java.awt.event.MouseEvent evt) {                                                       
        try{
            b3.posicionarBarcoH(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco3pasajerosHorizontal);
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }

    }                                                      

    private void barco4pasajerosVerticalMouseClicked(java.awt.event.MouseEvent evt) {                                                     
         try{
             b4.posicionarBarcoV(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco4pasajerosVertical);
         }
         catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }

    }                                                    

    private void barco3pasajerosVerticalMouseClicked(java.awt.event.MouseEvent evt) {                                                     
        try{
            b3.posicionarBarcoV(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco3pasajerosVertical);
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("ingreso un numero fuera de la matriz");
        }

    }                                                    

    private void barco4pasajerosHorizontal2MouseClicked(java.awt.event.MouseEvent evt) {                                                        
      try{
          b4.posicionarBarcoH(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco4pasajerosHorizontal2);
      }
      catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }

    }                                                       

    private void barco3pasajerosVertical2MouseClicked(java.awt.event.MouseEvent evt) {                                                      
              try{
                  b3.posicionarBarcoV(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco3pasajerosVertical2);
              }
              catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Error capturado");
        }
  
    }                                                     
/*
    private void barco2pasajerosHorizontal2MouseClicked(java.awt.event.MouseEvent evt) {                                                        


        //seleccion del barco de dos casillanarcs horizontal
    }                                                       
*/
    private void barco3pasajerosHorizontal2MouseClicked(java.awt.event.MouseEvent evt) {                                                        
     try{
         b3.posicionarBarcoH(player1, Integer.parseInt(fil.getText()),Integer.parseInt(col.getText()), barco3pasajerosHorizontal2);
     }
     catch(ArrayIndexOutOfBoundsException e)
        {
            
        }

    }                                                       

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         

        if (Barco_2.contador_de_barcos>2 && Barco_3.contador_de_barcos>1 && Barco_4.contador_de_barcos>1 && Barco_5.contador_de_barcos>0)
        {
          jPanel2.setSize(480,490) ; 
          Batalla_Naval_Comienzo nueva = new Batalla_Naval_Comienzo();
          nueva.setVisible(true);
          nueva.setLocation(480, 0);
          Jugadores p2= new Jugador_CPU();
          b2.resetContador();
          b3.resetContador();
          b4.resetContador();
          b5.resetContador();
          p2.crearJugador(Player2);
            
        }
        else
        {
            JOptionPane.showMessageDialog(null, "porfavor termine de llenar su flota");
        }
           
           
    }