miércoles, 28 de noviembre de 2012



Matrices 2

package paqMatrices2;

import javax.swing.JLabel;
import javax.swing.JTextField;

/**
 *
 * @author MOISES
 */
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||i==2)
               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());
         }
       }
    }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>                       

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jMatrices2().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                    
    // End of variables declaration                  

}

No hay comentarios:

Publicar un comentario