/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import Logica_Operaciones_BD.OperacionesCRUD;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

/**
 *
 * @author harol
 */
public class VentanaPrincipalJFrame extends javax.swing.JFrame {

    /**
     * Creates new form VentanaPrincipalJFrame
     */
    public VentanaPrincipalJFrame() {
        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() {

        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        total_carreras_jTextField = new javax.swing.JTextField();
        jButton_mostrarTotalCarreras = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable_ListaCarreras = new javax.swing.JTable();
        jButton_mostrarCarreras = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable_ListaParalelos = new javax.swing.JTable();
        jButton_mostrarParalelosCarrera = new javax.swing.JButton();
        jComboBox_Listado_Carreras_Paralelos = new javax.swing.JComboBox<>();
        jLabel2 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable_ListaEstudiantes = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        jComboBox_Listado_Carreras_Est = new javax.swing.JComboBox<>();
        jButton_mostrarEstudiantesCarrera = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jComboBox_Listado_Paralelos_Est = new javax.swing.JComboBox<>();
        jButton_mostrarEstudiantesParalelo = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Total de Carreras que oferta ITB:");

        total_carreras_jTextField.setEditable(false);

        jButton_mostrarTotalCarreras.setText("Mostrar");
        jButton_mostrarTotalCarreras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_mostrarTotalCarrerasActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(total_carreras_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton_mostrarTotalCarreras)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(total_carreras_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jButton_mostrarTotalCarreras)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTable_ListaCarreras.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "Listado de nombres de Carreras"
            }
        ));
        jScrollPane1.setViewportView(jTable_ListaCarreras);

        jButton_mostrarCarreras.setText("Mostrar");
        jButton_mostrarCarreras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_mostrarCarrerasActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(238, 238, 238)
                .addComponent(jButton_mostrarCarreras)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton_mostrarCarreras)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTable_ListaParalelos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "Listado de paralelos del ITB"
            }
        ));
        jScrollPane2.setViewportView(jTable_ListaParalelos);

        jButton_mostrarParalelosCarrera.setText("Mostrar");
        jButton_mostrarParalelosCarrera.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_mostrarParalelosCarreraActionPerformed(evt);
            }
        });

        jComboBox_Listado_Carreras_Paralelos.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel2.setText("Seleccione la carrera:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jComboBox_Listado_Carreras_Paralelos, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)))
                        .addComponent(jButton_mostrarParalelosCarrera)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox_Listado_Carreras_Paralelos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton_mostrarParalelosCarrera))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTable_ListaEstudiantes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Cédula", "Nombres", "Apellidos"
            }
        ));
        jScrollPane3.setViewportView(jTable_ListaEstudiantes);

        jLabel3.setText("Seleccione la carrera:");

        jComboBox_Listado_Carreras_Est.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox_Listado_Carreras_Est.setToolTipText("");

        jButton_mostrarEstudiantesCarrera.setText("Mostrar");
        jButton_mostrarEstudiantesCarrera.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_mostrarEstudiantesCarreraActionPerformed(evt);
            }
        });

        jLabel4.setText("Seleccione el paralelo:");

        jComboBox_Listado_Paralelos_Est.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jButton_mostrarEstudiantesParalelo.setText("Mostrar");
        jButton_mostrarEstudiantesParalelo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_mostrarEstudiantesParaleloActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 635, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(18, 18, 18)
                                .addComponent(jComboBox_Listado_Carreras_Est, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addGap(18, 18, 18)
                                .addComponent(jComboBox_Listado_Paralelos_Est, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton_mostrarEstudiantesCarrera)
                            .addComponent(jButton_mostrarEstudiantesParalelo, javax.swing.GroupLayout.Alignment.TRAILING))))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jComboBox_Listado_Carreras_Est, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton_mostrarEstudiantesCarrera))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jComboBox_Listado_Paralelos_Est, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton_mostrarEstudiantesParalelo))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        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(layout.createSequentialGroup()
                        .addGap(177, 177, 177)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6))
        );

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

    private void jButton_mostrarTotalCarrerasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_mostrarTotalCarrerasActionPerformed
        // TODO add your handling code here:
        //1. Obtener la instancia única objeto de la clase OperacionesCRUD
        OperacionesCRUD obj_CRUD = OperacionesCRUD.getInstance();
        try
        {
            //2. Obtener la cantidad de carreras del método (obtenerCantCarreras) que consulta a la BD y que implementa el objeto obj_BD (OperacionesCRUD)
            int totalCarreras = obj_CRUD.obtenerCantCarreras();
            String value = String.valueOf(totalCarreras);
            //3. Mostrar en el componente visual total_carreras_jTextField el valor de cantidad de carreras obtenido en el paso 2.
            total_carreras_jTextField.setText(value);
        }
        catch(SQLException err)
        {
            System.out.println(err.getMessage());
        }        
    }//GEN-LAST:event_jButton_mostrarTotalCarrerasActionPerformed
    //OK
    private void jButton_mostrarCarrerasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_mostrarCarrerasActionPerformed
        // TODO add your handling code here:
        //1. Obtener la instancia única objeto de la clase OperacionesCRUD
        OperacionesCRUD obj_CRUD = OperacionesCRUD.getInstance();
        try
        {            
            //2. Obtener el vector lista de carreras del método (obtenerListadoCarreras) que consulta a la BD y que implementa el objeto obj_BD (OperacionesCRUD)
            Vector<String> listado_carreras = obj_CRUD.obtenerListadoCarreras();
            //3. Crear el objeto DefaultTableModel del jTable_ListaCarreras que debe mostrar el vector lista de carreras
            DefaultTableModel tablaVisual = (DefaultTableModel) jTable_ListaCarreras.getModel();
            //4. Setear el componente jTable_ListaCarreras con cero filas y columna de datos a mostrar.
            tablaVisual.setRowCount(0);
            tablaVisual.setColumnCount(0);
            //5. Agregar la columna de datos con cabecera "Listado de Paralelos del ITB" y vector lista de datos.
            tablaVisual.addColumn("Listado de nombres de Carreras", listado_carreras);
        }
        catch(SQLException err)
        {
            err.printStackTrace();
        } 
    }//GEN-LAST:event_jButton_mostrarCarrerasActionPerformed

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
        // TODO add your handling code here:
        OperacionesCRUD obj_BD = OperacionesCRUD.getInstance();
        DefaultComboBoxModel<String> recordList_Carr_Est = (DefaultComboBoxModel)jComboBox_Listado_Carreras_Est.getModel();
        DefaultComboBoxModel<String> recordList_Carr_Paralelos = (DefaultComboBoxModel)jComboBox_Listado_Carreras_Paralelos.getModel();
        
        recordList_Carr_Est.removeAllElements();
        recordList_Carr_Paralelos.removeAllElements();
        
        try
        {
            Vector<String> listado_carreas = obj_BD.obtenerListadoCarreras();         
            int cant_carreras = listado_carreas.size();
            for (int fila = 0; fila < cant_carreras; fila++)
            {                
                String nombre_carrera = listado_carreas.get(fila);
                recordList_Carr_Est.addElement(nombre_carrera);
                recordList_Carr_Paralelos.addElement(nombre_carrera);
            }
            recordList_Carr_Est.setSelectedItem(listado_carreas.get(0));
            recordList_Carr_Paralelos.setSelectedItem(listado_carreas.get(0));
        }
        
        catch(SQLException err)
        {
            err.printStackTrace();
        }
        
        DefaultComboBoxModel<String> recordList_Paralelos_Est = (DefaultComboBoxModel)jComboBox_Listado_Paralelos_Est.getModel();
        recordList_Paralelos_Est.removeAllElements();
        
        try
        {
            Vector<String> listado_paralelos_est = obj_BD.obtenerListaParalelos();
            int cant_paralelos = listado_paralelos_est.size();
            for(int fila = 0; fila < cant_paralelos; fila++)
            {
                String codigo_paralelo = listado_paralelos_est.get(fila);
                recordList_Paralelos_Est.addElement(codigo_paralelo);
            }
            recordList_Paralelos_Est.setSelectedItem(listado_paralelos_est.get(0));
        }
        catch(SQLException err)
        {
            err.printStackTrace();
        }
    }//GEN-LAST:event_formComponentShown
    
    private void jButton_mostrarEstudiantesCarreraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_mostrarEstudiantesCarreraActionPerformed
        // TODO add your handling code here:
        //1. Obtener la instancia única objeto de la clase OperacionesCRUD
        OperacionesCRUD obj_BD = OperacionesCRUD.getInstance();
        //2. Obtener la lista de valores del modelo del combobox de lista de carreras.
        DefaultComboBoxModel<String> recordList_Carr_Est = (DefaultComboBoxModel)jComboBox_Listado_Carreras_Est.getModel();
        //3. Obtener la carrera seleccionado desde el combobox jComboBox_Listado_Carreras_Est
       String carrera = (String) recordList_Carr_Est.getSelectedItem();
        try
        {
            //4. Obtener la matriz de datos que devuelve el método (obtenerEstudInscritosPorCarrera) que consulta a la BD y que implementa el objeto obj_BD (OperacionesCRUD)
           ArrayList<Vector<String>> consulta = obj_BD.obtenerEstudInscritosPorCarrera(carrera);      
            //5. Crear el objeto DefaultTableModel del jTable que debe mostrar la matriz de datos de los estudiantes que están inscritos en una carrera en particular
            DefaultTableModel tablaVisual = (DefaultTableModel) jTable_ListaEstudiantes.getModel();
            //6. Setear el componente jTable_ListaEstudiantes con cero filas a mostrar.
            tablaVisual.setRowCount(0);
            //7. Obtener la cantidad de filas que arroja la consulta a la base de datos almacenada en la matriz de datos.
            int totalFilas = consulta.size();
            //8. Recorrer cada fila de la matriz de datos de los estudiantes inscritos en una carrera en particular y para cada iteración resolver:
            for (int i = 0; i < totalFilas; i++) 
            {
            Vector filaDatos =(Vector) consulta.get(i);        
            tablaVisual.addRow(filaDatos);
            
            }
        }
        catch(SQLException err)
        {
            err.printStackTrace();
        }         
    }//GEN-LAST:event_jButton_mostrarEstudiantesCarreraActionPerformed
    //OK
    private void jButton_mostrarParalelosCarreraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_mostrarParalelosCarreraActionPerformed
        // TODO add your handling code here:
        //1. Obtener la instancia única objeto de la clase OperacionesCRUD
        OperacionesCRUD obj_BD = OperacionesCRUD.getInstance();
        //2. Obtener la lista de valores del modelo del combobox de lista de carreras.
        DefaultComboBoxModel<String> recordList_Carr_Paralelos = (DefaultComboBoxModel)jComboBox_Listado_Carreras_Paralelos.getModel();
        //3. Obtener la carrera seleccionada desde el combobox jComboBox_Listado_Carreras_Paralelos
        String lista = (String) recordList_Carr_Paralelos.getSelectedItem();
        try
        {            
            //4. Obtener el vector lista de paralelos del método (obtenerListaParalelosCarrera) que consulta a la BD y que implementa el objeto obj_BD (OperacionesCRUD)
           Vector<String> lista_paralelos_codigo = obj_BD.obtenerListaParalelosCarrera(lista);         
            //5. Crear el objeto DefaultTableModel del jTable que debe mostrar el vector lista de paralelos
            DefaultTableModel tablaVisual = (DefaultTableModel) jTable_ListaParalelos.getModel();
            //6. Setear el componente jTable_ListaParalelos con cero filas y columna de datos a mostrar.
            tablaVisual.setRowCount(0);
            tablaVisual.setColumnCount(0);
            //7. Agregar la columna de datos con cabecera "Listado de Paralelos del ITB" y vector lista de datos "lista_paralelos".
            tablaVisual.addColumn("Listado de Paralelos del ITB", lista_paralelos_codigo);           
        }
        catch(SQLException err)
        {
            err.printStackTrace();
        } 
    }//GEN-LAST:event_jButton_mostrarParalelosCarreraActionPerformed
    //OK
    private void jButton_mostrarEstudiantesParaleloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_mostrarEstudiantesParaleloActionPerformed
        // TODO add your handling code here:
        //1. Obtener la instancia única objeto de la clase OperacionesCRUD
        OperacionesCRUD obj_BD = OperacionesCRUD.getInstance();
        //2. Obtener la lista de valores del modelo del combobox de lista de paralelos.
        DefaultComboBoxModel<String> recordList_Paralelos_Est = (DefaultComboBoxModel)jComboBox_Listado_Paralelos_Est.getModel();
        //3. Obtener el paralelo seleccionado desde el combobox jComboBox_Listado_Paralelos_Est
        String paralelo = (String) recordList_Paralelos_Est.getSelectedItem();  
        try
        {   
            //4. Obtener la matriz de datos que devuelve el método (obtenerEstudInscritosPorParalelo) que consulta a la BD y que implementa el objeto obj_BD (OperacionesCRUD)
            ArrayList<Vector<String>> consulta = obj_BD.obtenerEstudInscritosPorParalelo(paralelo);   
            //5. Crear el objeto DefaultTableModel del jTable que debe mostrar la matriz de datos de los estudiantes que están inscritos en un paralelo en particular
            DefaultTableModel tablaVisual = (DefaultTableModel) jTable_ListaEstudiantes.getModel();
            //6. Setear el componente jTable_ListaEstudiantes con cero filas a mostrar.
            tablaVisual.setRowCount(0);
            //7. Obtener la cantidad de filas que arroja la consulta a la base de datos almacenada en la matriz de datos.
            int totalFilas = consulta.size();
            //8. Recorrer cada fila de la matriz de datos de los estudiantes inscritos en un paralelo en particular y para cada iteración resolver:
            for (int i = 0; i < totalFilas; i++) 
            {
                Vector filaDatos =(Vector) consulta.get(i);        
            tablaVisual.addRow(filaDatos);
            
            }
        }
        catch(SQLException err)
        {
            err.printStackTrace();
        }
    }//GEN-LAST:event_jButton_mostrarEstudiantesParaleloActionPerformed

    /**
     * @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(VentanaPrincipalJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipalJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipalJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipalJFrame.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 VentanaPrincipalJFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_mostrarCarreras;
    private javax.swing.JButton jButton_mostrarEstudiantesCarrera;
    private javax.swing.JButton jButton_mostrarEstudiantesParalelo;
    private javax.swing.JButton jButton_mostrarParalelosCarrera;
    private javax.swing.JButton jButton_mostrarTotalCarreras;
    private javax.swing.JComboBox<String> jComboBox_Listado_Carreras_Est;
    private javax.swing.JComboBox<String> jComboBox_Listado_Carreras_Paralelos;
    private javax.swing.JComboBox<String> jComboBox_Listado_Paralelos_Est;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable jTable_ListaCarreras;
    private javax.swing.JTable jTable_ListaEstudiantes;
    private javax.swing.JTable jTable_ListaParalelos;
    private javax.swing.JTextField total_carreras_jTextField;
    // End of variables declaration//GEN-END:variables
}
