viernes, 23 de noviembre de 2012


9. TALLER DE PROGRAMACIÓN

PROGRAMA QUE UTILIZA LOS "ARREGLOS BIDIMENCIONALES"
MATRICES

1. Código Fuente en NetBeans

public class jMatrices2 extends javax.swing.JFrame {

    /** Creates new form jMatrices2 */
    public jMatrices2() {
        initComponents();
        JLabel[][] Campos=new JLabel[4][4];
        for(int i=0; i<4; i++){
            for(int j=0; j<4; j++){
                Campos[i][j]=new JLabel("1");
                Campos[i][j].setBounds((80*i)+10,(40*j)+10,80,40);
                this.add(Campos[i][j]);
                Campos[i][j].setVisible(true);
            }
        }

        Integer [][] numeros=new Integer[4][4];
        Integer c=1;
        for(int i=0; i<4; i++){
           for(int j=0; j<4; j++){
               if((i==0&&j==0)||(i==1&&j==1)||(i==2&&j==2)||(i==3&&j==3)){
               numeros[i][j]=1;
               }
           else{
               numeros[i][j]=0;
           }
         }
        }
        
       for(int i=0; i<4; i++){
         for(int j=0; j<4; j++){
             Campos[i][j].setText(numeros[i][j].toString());
         }
       }
    }

2.Comprimido del programa

No hay comentarios:

Publicar un comentario