Buscar este blog

jueves, 28 de febrero de 2013

Codigo Triqui



package triqui;

import java.awt.Color;

public class Pantalla extends javax.swing.JFrame {
    int a;
    String x="x";
    String o="0";
 String p,b,c,d,e,f,g,h,i;

    /**
     * Creates new form Pantalla
     */
    public Pantalla() {
        initComponents();
         A.setBackground(java.awt.Color.CYAN);
                B.setBackground(java.awt.Color.cyan);
                C.setBackground(java.awt.Color.cyan);
        D.setBackground(java.awt.Color.cyan);
            E.setBackground(java.awt.Color.cyan);
            F.setBackground(java.awt.Color.cyan);
         G.setBackground(java.awt.Color.cyan);
            I.setBackground(java.awt.Color.cyan);
            H.setBackground(java.awt.Color.cyan);
       
    }

 
    @SuppressWarnings("unchecked")
   
 
    private void initComponents() {

       

    private void jugaor1MouseClicked(java.awt.event.MouseEvent evt) {                                    
       a=1;
        jugaor1.setBackground(java.awt.Color.yellow);
        jugador2.setBackground(null);
    }                                  

    private void jugador2MouseClicked(java.awt.event.MouseEvent evt) {                                    
       a=2;
       jugador2.setBackground(java.awt.Color.yellow);
       jugaor1.setBackground(null);
    }                                    

    private void AMouseClicked(java.awt.event.MouseEvent evt) {                              
     
// en este ejemplo el color de fondo es amarillo
        p=this.A.getText();
        b=this.B.getText();
        c=this.C.getText();
        d=this.D.getText();
        e=this.E.getText();
        f=this.F.getText();
        g=this.G.getText();
        h=this.H.getText();
        i=this.I.getText();
        if(a==1){
           A.setText(x);
         
       }
       if(a==2){
           A.setText(o);
         
         
         
       }
        if (this.A.getText().equals(this.B.getText())){
        if (this.A.getText().equals(this.C.getText())){
            if(this.A.getText().equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
             
             A.setBackground(java.awt.Color.yellow);
                B.setBackground(java.awt.Color.yellow);
                C.setBackground(java.awt.Color.yellow);
                }
            if(this.A.getText().equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 A.setBackground(java.awt.Color.yellow);
                B.setBackground(java.awt.Color.yellow);
                C.setBackground(java.awt.Color.yellow);
            }
           
           
               
        }
        }
         if (this.A.getText().equals(d)){
        if (p.equals(g)){
            if(p.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
         
            A.setBackground(java.awt.Color.RED);
            D.setBackground(java.awt.Color.RED);
             G.setBackground(java.awt.Color.RED);
                }
            if(p.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 A.setBackground(java.awt.Color.RED);
            D.setBackground(java.awt.Color.RED);
             G.setBackground(java.awt.Color.RED);
            }
           
        }
        }
         if (p.equals(e)){
        if (p.equals(i)){
            if(p.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
            A.setBackground(java.awt.Color.RED);
            E.setBackground(java.awt.Color.RED);
            I.setBackground(java.awt.Color.RED);
                }
            if(p.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 A.setBackground(java.awt.Color.RED);
            E.setBackground(java.awt.Color.RED);
            I.setBackground(java.awt.Color.RED);
            }
           
        }
        }
       
    }                            

    private void BMouseClicked(java.awt.event.MouseEvent evt) {                              
         p=this.A.getText();
        b=this.B.getText();
        c=this.C.getText();
        d=this.D.getText();
        e=this.E.getText();
        f=this.F.getText();
        g=this.G.getText();
        h=this.H.getText();
        i=this.I.getText();
        if(a==1){
           B.setText(x);
         
       }
       if(a==2){
           B.setText(o);
         
       }
        if (p.equals(b)){
        if (p.equals(c)){
            if(p.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
             
             A.setBackground(java.awt.Color.yellow);
                B.setBackground(java.awt.Color.yellow);
                C.setBackground(java.awt.Color.yellow);
                }
            if(p.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 A.setBackground(java.awt.Color.yellow);
                B.setBackground(java.awt.Color.yellow);
                C.setBackground(java.awt.Color.yellow);
            }
           
           
               
        }
        }
         if (b.equals(e)){
        if (b.equals(h)){
            if(b.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
            B.setBackground(java.awt.Color.GREEN);
            E.setBackground(java.awt.Color.GREEN);
            H.setBackground(java.awt.Color.GREEN);
                }
            if(b.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 B.setBackground(java.awt.Color.GREEN);
            E.setBackground(java.awt.Color.GREEN);
            H.setBackground(java.awt.Color.GREEN);
            }
         
        }
        }
    }                            

    private void CMouseClicked(java.awt.event.MouseEvent evt) {                              
        p=this.A.getText();
        b=this.B.getText();
        c=this.C.getText();
        d=this.D.getText();
        e=this.E.getText();
        f=this.F.getText();
        g=this.G.getText();
        h=this.H.getText();
        i=this.I.getText();
        if(a==1){
           C.setText(x);
         
       }
       if(a==2){
           C.setText(o);
         
       }  
        if (p.equals(b)){
        if (p.equals(c)){
            if(p.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
                A.setBackground(java.awt.Color.yellow);
                B.setBackground(java.awt.Color.yellow);
                C.setBackground(java.awt.Color.yellow);
           
                }
            if(p.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 A.setBackground(java.awt.Color.yellow);
                B.setBackground(java.awt.Color.yellow);
                C.setBackground(java.awt.Color.yellow);
            }
           
           
               
        }
        }
         if (c.equals(f)){
        if (c.equals(i)){
            if(c.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
            C.setBackground(java.awt.Color.yellow);
            F.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
                }
            if(c.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 C.setBackground(java.awt.Color.yellow);
            F.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
            }
         
        }
        }
          if (c.equals(e)){
        if (c.equals(g)){
            if(c.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
             C.setBackground(java.awt.Color.BLUE);
            G.setBackground(java.awt.Color.BLUE);
            E.setBackground(java.awt.Color.BLUE);
                }
            if(c.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 C.setBackground(java.awt.Color.BLUE);
            G.setBackground(java.awt.Color.BLUE);
            E.setBackground(java.awt.Color.BLUE);
            }
         
        }
        }
    }                            

    private void DMouseClicked(java.awt.event.MouseEvent evt) {                              
        p=this.A.getText();
        b=this.B.getText();
        c=this.C.getText();
        d=this.D.getText();
        e=this.E.getText();
        f=this.F.getText();
        g=this.G.getText();
        h=this.H.getText();
        i=this.I.getText();
        if(a==1){
           D.setText(x);
         
       }
       if(a==2){
           D.setText(o);
         
       }      
        if (d.equals(e)){
        if (d.equals(f)){
            if(d.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
           D.setBackground(java.awt.Color.GREEN);
            E.setBackground(java.awt.Color.GREEN);
            F.setBackground(java.awt.Color.GREEN);
                }
            if(d.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                D.setBackground(java.awt.Color.GREEN);
            E.setBackground(java.awt.Color.GREEN);
            F.setBackground(java.awt.Color.GREEN);
            }
           
        }
        }
         if (p.equals(d)){
        if (p.equals(g)){
            if(p.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
            A.setBackground(java.awt.Color.RED);
            D.setBackground(java.awt.Color.RED);
             G.setBackground(java.awt.Color.RED);
         
                }
            if(p.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 A.setBackground(java.awt.Color.RED);
            D.setBackground(java.awt.Color.RED);
             G.setBackground(java.awt.Color.RED);
            }
           
        }
        }
    }                            

    private void EMouseClicked(java.awt.event.MouseEvent evt) {                              
         p=this.A.getText();
        b=this.B.getText();
        c=this.C.getText();
        d=this.D.getText();
        e=this.E.getText();
        f=this.F.getText();
        g=this.G.getText();
        h=this.H.getText();
        i=this.I.getText();
        if(a==1){
           E.setText(x);
         
       }
       if(a==2){
           E.setText(o);
         
       }
       if (p.equals(e)){
        if (p.equals(i)){
            if(p.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
            A.setBackground(java.awt.Color.RED);
            E.setBackground(java.awt.Color.RED);
            I.setBackground(java.awt.Color.RED);
                }
            if(p.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 A.setBackground(java.awt.Color.RED);
            E.setBackground(java.awt.Color.RED);
            I.setBackground(java.awt.Color.RED);
            }
           
        }
        }
        if (d.equals(e)){
        if (d.equals(f)){
            if(d.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
           D.setBackground(java.awt.Color.GREEN);
            E.setBackground(java.awt.Color.GREEN);
            F.setBackground(java.awt.Color.GREEN);
                }
            if(d.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                D.setBackground(java.awt.Color.GREEN);
            E.setBackground(java.awt.Color.GREEN);
            F.setBackground(java.awt.Color.GREEN);
            }
           
        }
        }
         if (c.equals(e)){
        if (c.equals(g)){
            if(c.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
             C.setBackground(java.awt.Color.BLUE);
            G.setBackground(java.awt.Color.BLUE);
            E.setBackground(java.awt.Color.BLUE);
                }
            if(c.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 C.setBackground(java.awt.Color.BLUE);
            G.setBackground(java.awt.Color.BLUE);
            E.setBackground(java.awt.Color.BLUE);
            }
         
        }
        }
    }                            

    private void FMouseClicked(java.awt.event.MouseEvent evt) {                              
        p=this.A.getText();
        b=this.B.getText();
        c=this.C.getText();
        d=this.D.getText();
        e=this.E.getText();
        f=this.F.getText();
        g=this.G.getText();
        h=this.H.getText();
        i=this.I.getText();
        if(a==1){
           F.setText(x);
         
       }
       if(a==2){
           F.setText(o);
         
       }      
        if (d.equals(e)){
        if (d.equals(f)){
            if(d.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
           D.setBackground(java.awt.Color.GREEN);
            E.setBackground(java.awt.Color.GREEN);
            F.setBackground(java.awt.Color.GREEN);
                }
            if(d.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                D.setBackground(java.awt.Color.GREEN);
            E.setBackground(java.awt.Color.GREEN);
            F.setBackground(java.awt.Color.GREEN);
            }
           
        }
        }
         if (c.equals(f)){
        if (c.equals(i)){
            if(c.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
            C.setBackground(java.awt.Color.yellow);
            F.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
                }
            if(c.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 C.setBackground(java.awt.Color.yellow);
            F.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
            }
         
        }
        }
    }                            

    private void GMouseClicked(java.awt.event.MouseEvent evt) {                              
         p=this.A.getText();
        b=this.B.getText();
        c=this.C.getText();
        d=this.D.getText();
        e=this.E.getText();
        f=this.F.getText();
        g=this.G.getText();
        h=this.H.getText();
        i=this.I.getText();
        if(a==1){
           G.setText(x);
         
       }
       if(a==2){
           G.setText(o);
         
       }      
       if (g.equals(h)){
        if (g.equals(i)){
            if(g.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
             G.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
            H.setBackground(java.awt.Color.yellow);
                }
            if(g.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 G.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
            H.setBackground(java.awt.Color.yellow);
            }
         
        }
        }
        if (p.equals(d)){
        if (p.equals(g)){
            if(p.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
            A.setBackground(java.awt.Color.RED);
            D.setBackground(java.awt.Color.RED);
             G.setBackground(java.awt.Color.RED);
         
                }
            if(p.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 A.setBackground(java.awt.Color.RED);
            D.setBackground(java.awt.Color.RED);
             G.setBackground(java.awt.Color.RED);
            }
           
        }
        }
         if (c.equals(e)){
        if (c.equals(g)){
            if(c.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
             C.setBackground(java.awt.Color.BLUE);
            G.setBackground(java.awt.Color.BLUE);
            E.setBackground(java.awt.Color.BLUE);
                }
            if(c.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 C.setBackground(java.awt.Color.BLUE);
            G.setBackground(java.awt.Color.BLUE);
            E.setBackground(java.awt.Color.BLUE);
            }
         
        }
        }
    }                            

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

        p=this.A.getText();
        b=this.B.getText();
        c=this.C.getText();
        d=this.D.getText();
        e=this.E.getText();
        f=this.F.getText();
        g=this.G.getText();
        h=this.H.getText();
        i=this.I.getText();
        if(a==1){
           H.setText(x);
         
       }
       if(a==2){
           H.setText(o);
         
       }    
       if (g.equals(h)){
        if (g.equals(i)){
            if(g.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
             G.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
            H.setBackground(java.awt.Color.yellow);
                }
            if(g.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 G.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
            H.setBackground(java.awt.Color.yellow);
            }
         
        }
        }
        if (b.equals(e)){
        if (b.equals(h)){
            if(b.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
            B.setBackground(java.awt.Color.GREEN);
            E.setBackground(java.awt.Color.GREEN);
            H.setBackground(java.awt.Color.GREEN);
                }
            if(b.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 B.setBackground(java.awt.Color.GREEN);
            E.setBackground(java.awt.Color.GREEN);
            H.setBackground(java.awt.Color.GREEN);
            }
         
        }
        }
    }                            

    private void IMouseClicked(java.awt.event.MouseEvent evt) {                              
        p=this.A.getText();
        b=this.B.getText();
        c=this.C.getText();
        d=this.D.getText();
        e=this.E.getText();
        f=this.F.getText();
        g=this.G.getText();
        h=this.H.getText();
        i=this.I.getText();
        if(a==1){
           I.setText(x);
         
       }
       if(a==2){
           I.setText(o);
         
       }    
       if (p.equals(e)){
        if (p.equals(i)){
            if(p.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
             A.setBackground(java.awt.Color.RED);
            E.setBackground(java.awt.Color.RED);
            I.setBackground(java.awt.Color.RED);
                }
            if(p.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                  A.setBackground(java.awt.Color.RED);
            E.setBackground(java.awt.Color.RED);
            I.setBackground(java.awt.Color.RED);
            }
         
        }
        }
       if (g.equals(h)){
        if (g.equals(i)){
            if(g.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
             G.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
            H.setBackground(java.awt.Color.yellow);
                }
            if(g.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 G.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
            H.setBackground(java.awt.Color.yellow);
            }
         
        }
        }
        if (c.equals(f)){
        if (c.equals(i)){
            if(c.equals(x)){
            Tex.setText("triqui el jugador 1 ha ganado");
            C.setBackground(java.awt.Color.yellow);
            F.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
                }
            if(c.equals(o)){
                Tex.setText("triqui el jugador 2 ha ganado");
                 C.setBackground(java.awt.Color.yellow);
            F.setBackground(java.awt.Color.yellow);
            I.setBackground(java.awt.Color.yellow);
            }
         
        }
        }
    }                            

    private void jButton10MouseClicked(java.awt.event.MouseEvent evt) {                                      
     
       
          Inicio miinicio =new Inicio();
        miinicio.setVisible(true);
        this.setVisible(false);
     
    }                                    

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
    }                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Pantalla.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Pantalla.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Pantalla.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Pantalla.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
       

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Pantalla().setVisible(true);
            }
        });
    }
   
    private javax.swing.JButton A;
    private javax.swing.JButton B;
    private javax.swing.JButton C;
    private javax.swing.JButton D;
    private javax.swing.JButton E;
    private javax.swing.JButton F;
    private javax.swing.JButton G;
    private javax.swing.JButton H;
    private javax.swing.JButton I;
    private javax.swing.JLabel Letrero;
    private javax.swing.JLabel Tex;
    private javax.swing.JButton jButton10;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JButton jugador2;
    private javax.swing.JButton jugaor1;
   
}

No hay comentarios:

Publicar un comentario