private void jButton2MousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jButton2MousePressed
    // TODO add your handling code here:
    if (jTable1.getSelectedRow() == -1) {
      JOptionPane.showMessageDialog(null, "Para modidficar debe seleccionar el curso postgrado.");
    } else {
      Integer fila = jTable1.getSelectedRow();
      if (jTable1.getValueAt(fila, 0) == null || jTable1.getSelectedRowCount() > 1)
        JOptionPane.showMessageDialog(null, "Debe seleccionar un curso postgrado.");
      else {
        if (jTextField1.getText().isEmpty() || jTextArea1.getText().isEmpty())
          JOptionPane.showMessageDialog(null, "No debe dejar campos vacios.");
        else {
          CursoPControl cpc = new CursoPControl();

          if (cpc.existe(jTextField1.getText())
              && jTextField1.getText().equalsIgnoreCase(String.valueOf(jTable1.getValueAt(fila, 0)))
                  == false) {
            JOptionPane.showMessageDialog(null, "Ya existe el curso postgrado.");
          } else {
            try {
              int id = cpc.buscarIdCursoP(String.valueOf(jTable1.getValueAt(fila, 0)));
              cpc.actualizarCursoP(jTextField1.getText(), jTextArea1.getText(), id);
              CursoPostgrado curso = cpc.buscarCursoPId(id);
              cursoPostgradoList.remove(curso);
              cursoPostgradoList.add(curso);
              jTextField1.setText("");
              jTextArea1.setText("");
            } catch (PreexistingEntityException ex) {
              Logger.getLogger(GestionarCursoPostgrado.class.getName()).log(Level.SEVERE, null, ex);
            } catch (Exception ex) {
              Logger.getLogger(GestionarCursoPostgrado.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        }
      }
    }
  } // GEN-LAST:event_jButton2MousePressed
 private void jButton1MousePressed(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jButton1MousePressed
   // TODO add your handling code here:
   if (jTable1.getSelectedRow() != -1) {
     jTable1.clearSelection();
     JOptionPane.showMessageDialog(
         null, "Para insertar no debe tener ningún curso postgrado seleccionado.");
     jTextField1.setText("");
     jTextArea1.setText("");
   } else {
     if (jTextField1.getText().isEmpty() || jTextArea1.getText().isEmpty()) {
       JOptionPane.showMessageDialog(null, "No debe dejar campos vacíos.");
     } else {
       CursoPControl cpc = new CursoPControl();
       if (cpc.existe(jTextField1.getText())) {
         JOptionPane.showMessageDialog(null, "Este curso postgrado ya existe.");
         jTextField1.setText("");
         jTextArea1.setText("");
       } else {
         try {
           String nombre = jTextField1.getText();
           String descripcion = jTextArea1.getText();
           CursoPostgrado cp = new CursoPostgrado();
           cp.setDescripcionPostgrado(descripcion);
           cp.setTipoPostgrado(nombre);
           cpc.adicionar(cp);
           cursoPostgradoList.add(cp);
           jTextField1.setText("");
           jTextArea1.setText("");
         } catch (PreexistingEntityException ex) {
           Logger.getLogger(GestionarCursoPostgrado.class.getName()).log(Level.SEVERE, null, ex);
         } catch (Exception ex) {
           Logger.getLogger(GestionarCursoPostgrado.class.getName()).log(Level.SEVERE, null, ex);
         }
       }
     }
   }
 } // GEN-LAST:event_jButton1MousePressed