/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JFvercolumnas.java
 *
 * Created on 19-jul-2010, 14:04:39
 */

package vistas;

import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultListModel;

/**
 *
 * @author Adrian
 */
public class JFvercolumnas extends javax.swing.JFrame {

    JFprincipal p = new JFprincipal();

    /** Creates new form JFvercolumnas */
    public JFvercolumnas() {
        initComponents();
    }

    /** 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">//GEN-BEGIN:initComponents
    private void initComponents() {

        mensaje = new javax.swing.JLabel();
        columna1 = new javax.swing.JLabel();
        columna2 = new javax.swing.JLabel();
        columna3 = new javax.swing.JLabel();
        columna4 = new javax.swing.JLabel();
        columna5 = new javax.swing.JLabel();
        columna6 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jButton1 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        jScrollPane3 = new javax.swing.JScrollPane();
        jList3 = new javax.swing.JList();
        jScrollPane4 = new javax.swing.JScrollPane();
        jList4 = new javax.swing.JList();
        jScrollPane5 = new javax.swing.JScrollPane();
        jList5 = new javax.swing.JList();
        jScrollPane6 = new javax.swing.JScrollPane();
        jList6 = new javax.swing.JList();
        columna7 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        jList7 = new javax.swing.JList();
        jScrollPane8 = new javax.swing.JScrollPane();
        jList8 = new javax.swing.JList();
        columna8 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });

        mensaje.setFont(new java.awt.Font("Tahoma", 1, 12));

        columna1.setText("Columna1");

        columna2.setText("Columna 2");

        columna3.setText("Columna 3");

        columna4.setText("Columna 4");

        columna5.setText("Columna 5");

        columna6.setText("Columna 6");

        jList1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jList1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jList1.setForeground(new java.awt.Color(0, 102, 0));
        jList1.setEnabled(false);
        jScrollPane1.setViewportView(jList1);

        jButton1.setText("Aceptar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jList2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jList2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jList2.setForeground(new java.awt.Color(0, 102, 0));
        jList2.setEnabled(false);
        jScrollPane2.setViewportView(jList2);

        jList3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jList3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jList3.setForeground(new java.awt.Color(0, 102, 0));
        jList3.setEnabled(false);
        jScrollPane3.setViewportView(jList3);

        jList4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jList4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jList4.setForeground(new java.awt.Color(0, 102, 0));
        jList4.setEnabled(false);
        jScrollPane4.setViewportView(jList4);

        jList5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jList5.setFont(new java.awt.Font("Tahoma", 1, 11));
        jList5.setForeground(new java.awt.Color(0, 102, 0));
        jList5.setEnabled(false);
        jScrollPane5.setViewportView(jList5);

        jList6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jList6.setFont(new java.awt.Font("Tahoma", 1, 11));
        jList6.setForeground(new java.awt.Color(0, 102, 0));
        jList6.setEnabled(false);
        jScrollPane6.setViewportView(jList6);

        columna7.setText("Columna 7");

        jList7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jList7.setFont(new java.awt.Font("Tahoma", 1, 11));
        jList7.setForeground(new java.awt.Color(0, 102, 0));
        jList7.setEnabled(false);
        jScrollPane7.setViewportView(jList7);

        jList8.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jList8.setFont(new java.awt.Font("Tahoma", 1, 11));
        jList8.setForeground(new java.awt.Color(0, 102, 0));
        jList8.setEnabled(false);
        jScrollPane8.setViewportView(jList8);

        columna8.setText("Columna 8");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(columna1)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(33, 33, 33)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(columna2)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(32, 32, 32)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(columna3)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(31, 31, 31)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(columna4)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(36, 36, 36)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(columna5)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(35, 35, 35)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(columna6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(columna7)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(35, 35, 35)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(columna8)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(mensaje, javax.swing.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(52, 52, 52)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(mensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(columna8)
                            .addComponent(columna7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(columna1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(columna6)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(columna5)
                                        .addComponent(columna4)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(columna3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(columna2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(22, 22, 22))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //Cuando el formulario se activa
    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        // TODO add your handling code here:
        //Si no hay columnas
        if(p.cliente.getColumnas().size() == 0)
        mensaje.setText("No hay ninguna columna introducida");
        else
          mensaje.setText("Tiene "+ p.cliente.getColumnas().size() + " columnas introducidas" );

        //Si hay columna
        if(p.cliente.getColumnas().size() != 0){
            int i = 0;
            List <Integer> aux = new ArrayList();
            //CREAMOS UN NUEVO MODELO PARA PODER AGREGAR A EL JLIST
            DefaultListModel mod1=new DefaultListModel();
            DefaultListModel mod2=new DefaultListModel();
            DefaultListModel mod3=new DefaultListModel();
            DefaultListModel mod4=new DefaultListModel();
            DefaultListModel mod5=new DefaultListModel();
            DefaultListModel mod6=new DefaultListModel();
            DefaultListModel mod7=new DefaultListModel();
            DefaultListModel mod8=new DefaultListModel();

            while(i < p.cliente.getColumnas().size()){ //mientras haya columnas
                aux = p.cliente.getColumnas().get(i).getNumeros(); //colgemos los 6 numeros

                //AGREGAMOS AL MODELO LOS ELEMENTOS
                int n;
                if(i==0) //si es la primera columna
                for(int j=0;j<aux.size();j++){ //hasta 6 numeros
                    n = aux.get(j);
                    mod1.addElement(n); //añadimos el elemento al modelo
                }
                    jList1.setModel(mod1);
                if(i==1) //si es la segunda columna
                for(int j=0;j<aux.size();j++){
                    n = aux.get(j);
                    mod2.addElement(n);
                }
                    jList2.setModel(mod2);
                if(i==2)
                for(int j=0;j<aux.size();j++){
                    n = aux.get(j);
                    mod3.addElement(n);
                }
                    jList3.setModel(mod3);
                if(i==3)
                for(int j=0;j<aux.size();j++){
                    n = aux.get(j);
                    mod4.addElement(n);
                }
                    jList4.setModel(mod4);
                if(i==4)
                for(int j=0;j<aux.size();j++){
                    n = aux.get(j);
                    mod5.addElement(n);
                }
                    jList5.setModel(mod5);
                if(i==5)
                for(int j=0;j<aux.size();j++){
                    n = aux.get(j);
                    mod6.addElement(n);
                }
                    jList6.setModel(mod6);
                if(i==6)
                for(int j=0;j<aux.size();j++){
                    n = aux.get(j);
                    mod7.addElement(n);
                }
                    jList7.setModel(mod7);
                if(i==7)
                for(int j=0;j<aux.size();j++){
                    n = aux.get(j);
                    mod8.addElement(n);
                }
                    jList8.setModel(mod8);
                i++; //otra columna
            }
        }
    }//GEN-LAST:event_formWindowActivated

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel columna1;
    private javax.swing.JLabel columna2;
    private javax.swing.JLabel columna3;
    private javax.swing.JLabel columna4;
    private javax.swing.JLabel columna5;
    private javax.swing.JLabel columna6;
    private javax.swing.JLabel columna7;
    private javax.swing.JLabel columna8;
    private javax.swing.JButton jButton1;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JList jList3;
    private javax.swing.JList jList4;
    private javax.swing.JList jList5;
    private javax.swing.JList jList6;
    private javax.swing.JList jList7;
    private javax.swing.JList jList8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JLabel mensaje;
    // End of variables declaration//GEN-END:variables

}
