public void registrar() {
    try {
      String cI = (String) CBinstructor.getSelectedItem();
      ArrayList<Usuario> listaU = new ArrayList<Usuario>();
      listaU = controladorHibernate.devolverCampo("Usuario", "Nombres", cI);
      int idI = 0;
      for (Usuario itemI : listaU) {
        idI = itemI.getIdUsuarios();
      }
      Usuario usuario = new Usuario();
      usuario.setIdUsuarios(idI);
      int numero = Integer.parseInt(CTnumero.getText());
      Date fechaSeguimiento = DCseguimiento.getDate();
      String ciudad = CTciudad.getText();
      String tipoInforme = (String) CBinforme.getSelectedItem();
      Date fechaInicial = DCFinicial.getDate();
      Date fechaFinal = DCFfinal.getDate();

      Seguimientos seguimiento =
          new Seguimientos(
              contratos,
              usuario,
              numero,
              fechaSeguimiento,
              ciudad,
              tipoInforme,
              fechaInicial,
              fechaFinal);
      controladorHibernate.insertarObjecto(seguimiento);
    } catch (Exception ex) {
      System.out.println("Error al registrar: " + ex.getMessage());
      ex.printStackTrace();
    }
  }
 private void CTciudadKeyTyped(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_CTciudadKeyTyped
   int k = (int) evt.getKeyChar();
   if (k > 47 && k < 58) {
     evt.setKeyChar((char) KeyEvent.VK_CLEAR);
     JOptionPane.showMessageDialog(
         null, "No puede ingresar numeros!!!", "Ventana Error Datos", JOptionPane.ERROR_MESSAGE);
   }
   if (k == 10) {
     CTciudad.transferFocus();
   }
 } // GEN-LAST:event_CTciudadKeyTyped
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
    try {
      boolean entrar = true;

      if ((CTciudad.getText().equals(""))
          || (CTnumero.getText().equals(""))
          || (CBinstructor.getSelectedItem().equals("--Seleccione un Instructor---"))) {
        JOptionPane.showMessageDialog(
            rootPane,
            "Por favor complete todos los campos",
            "Informacion...",
            JOptionPane.WARNING_MESSAGE);
        entrar = false;
      }

      if (entrar) {
        int opcion =
            JOptionPane.showConfirmDialog(
                rootPane,
                "Esta seguro de asignar este seguimiento?",
                "Confirmacion",
                JOptionPane.OK_CANCEL_OPTION);

        if (opcion == JOptionPane.OK_OPTION) {
          try {
            registrar();
            JOptionPane.showMessageDialog(
                rootPane,
                "Se asigno el seguimiento correctamente",
                "EnhoraBuena¡¡",
                JOptionPane.INFORMATION_MESSAGE);
            dispose();
          } catch (Exception e) {
            System.out.println("Error al insertar: " + e.getMessage());
            JOptionPane.showMessageDialog(
                rootPane,
                "Lo sentimos no se pudo asignar el seguimiento intetelo de nuevo",
                "Error¡¡",
                JOptionPane.WARNING_MESSAGE);
            e.printStackTrace();
          }
        }
      }
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(
          rootPane,
          "Por favor complete todos los campos",
          "Informacion....",
          JOptionPane.WARNING_MESSAGE);
    }
  } // GEN-LAST:event_jButton1ActionPerformed
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jTextField6 = new javax.swing.JTextField();
    jPanel1 = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    CTnumero = new javax.swing.JTextField();
    CTciudad = new javax.swing.JTextField();
    DCFinicial = new com.toedter.calendar.JDateChooser();
    DCFfinal = new com.toedter.calendar.JDateChooser();
    jButton1 = new javax.swing.JButton();
    CBinstructor = new javax.swing.JComboBox();
    CBinforme = new javax.swing.JComboBox();
    DCseguimiento = new com.toedter.calendar.JDateChooser();
    jButton2 = new javax.swing.JButton();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenu6 = new javax.swing.JMenu();
    jMenuItem3 = new javax.swing.JMenuItem();
    jMenu4 = new javax.swing.JMenu();
    jMenuItem2 = new javax.swing.JMenuItem();
    jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
    jMenu3 = new javax.swing.JMenu();
    jMenuItem4 = new javax.swing.JMenuItem();
    MnewUser = new javax.swing.JCheckBoxMenuItem();
    jMenu2 = new javax.swing.JMenu();
    jMenuItem5 = new javax.swing.JMenuItem();
    jMenuItem1 = new javax.swing.JMenuItem();

    jTextField6.setText("jTextField1");

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setUndecorated(true);
    setResizable(false);

    jPanel1.setBorder(
        javax.swing.BorderFactory.createTitledBorder(
            new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 2, true),
            "Asignar Seguimiento",
            javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
            javax.swing.border.TitledBorder.DEFAULT_POSITION,
            new java.awt.Font("Tahoma", 1, 13))); // NOI18N

    jLabel2.setText("Asignar Instructor");

    jLabel3.setText("Numero");

    jLabel4.setText("Fecha Seguimiento");

    jLabel5.setText("Ciudad");

    jLabel6.setText("Tipo Informe");

    jLabel7.setText("Fecha Inicial Periodo");

    jLabel8.setText("Fecha Final Periodo");

    CTnumero.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyTyped(java.awt.event.KeyEvent evt) {
            CTnumeroKeyTyped(evt);
          }
        });

    CTciudad.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyTyped(java.awt.event.KeyEvent evt) {
            CTciudadKeyTyped(evt);
          }
        });

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

    CBinforme.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"Parcial", "Final"}));

    jButton2.setText("Cancelar");
    jButton2.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel1Layout
                    .createSequentialGroup()
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addGap(36, 36, 36)
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                javax.swing.GroupLayout.Alignment.TRAILING,
                                                jPanel1Layout
                                                    .createParallelGroup(
                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addGroup(
                                                        jPanel1Layout
                                                            .createSequentialGroup()
                                                            .addComponent(jLabel3)
                                                            .addGap(81, 81, 81))
                                                    .addGroup(
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        jPanel1Layout
                                                            .createSequentialGroup()
                                                            .addComponent(jLabel2)
                                                            .addGap(31, 31, 31)))
                                            .addGroup(
                                                jPanel1Layout
                                                    .createSequentialGroup()
                                                    .addComponent(jLabel4)
                                                    .addGap(32, 32, 32)))
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(CTnumero)
                                            .addComponent(
                                                CBinstructor,
                                                0,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .addComponent(
                                                DCseguimiento,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                130,
                                                Short.MAX_VALUE)))
                            .addGroup(
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addGap(227, 227, 227)
                                    .addComponent(jLabel5)))
                    .addGap(159, 159, 159)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                javax.swing.GroupLayout.Alignment.TRAILING,
                                                jPanel1Layout
                                                    .createSequentialGroup()
                                                    .addComponent(jLabel7)
                                                    .addGap(52, 52, 52))
                                            .addGroup(
                                                jPanel1Layout
                                                    .createSequentialGroup()
                                                    .addGroup(
                                                        jPanel1Layout
                                                            .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment
                                                                    .LEADING)
                                                            .addComponent(jLabel6)
                                                            .addComponent(jLabel8)
                                                            .addGroup(
                                                                jPanel1Layout
                                                                    .createSequentialGroup()
                                                                    .addGap(15, 15, 15)
                                                                    .addComponent(
                                                                        jButton2,
                                                                        javax.swing.GroupLayout
                                                                            .PREFERRED_SIZE,
                                                                        94,
                                                                        javax.swing.GroupLayout
                                                                            .PREFERRED_SIZE)))
                                                    .addGap(41, 41, 41)))
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(
                                                jButton1,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .addComponent(
                                                DCFfinal,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .addComponent(
                                                DCFinicial,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .addComponent(
                                                CBinforme,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                130,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(
                                CTciudad,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                130,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(188, Short.MAX_VALUE)));
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel1Layout
                    .createSequentialGroup()
                    .addGap(47, 47, 47)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                CTciudad,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                33,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                    .addGap(22, 22, 22)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(
                                                CBinstructor,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                33,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(
                                                jPanel1Layout
                                                    .createSequentialGroup()
                                                    .addGap(9, 9, 9)
                                                    .addComponent(jLabel2)))
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                jPanel1Layout
                                                    .createSequentialGroup()
                                                    .addGap(27, 27, 27)
                                                    .addComponent(jLabel3))
                                            .addGroup(
                                                jPanel1Layout
                                                    .createSequentialGroup()
                                                    .addGap(18, 18, 18)
                                                    .addComponent(
                                                        CTnumero,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        33,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                jPanel1Layout
                                                    .createSequentialGroup()
                                                    .addGap(37, 37, 37)
                                                    .addComponent(jLabel4))
                                            .addGroup(
                                                jPanel1Layout
                                                    .createSequentialGroup()
                                                    .addGap(27, 27, 27)
                                                    .addComponent(
                                                        DCseguimiento,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        30,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addContainerGap(110, Short.MAX_VALUE))
                            .addGroup(
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(
                                                CBinforme,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                28,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(
                                                jLabel6,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                22,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                jPanel1Layout
                                                    .createSequentialGroup()
                                                    .addGap(27, 27, 27)
                                                    .addComponent(jLabel7))
                                            .addGroup(
                                                jPanel1Layout
                                                    .createSequentialGroup()
                                                    .addGap(18, 18, 18)
                                                    .addComponent(
                                                        DCFinicial,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        33,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGap(37, 37, 37)
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(
                                                DCFfinal,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                30,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel8))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(
                                                jButton1,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                33,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(
                                                jButton2,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                33,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(29, 29, 29)))));

    jMenu1.setText("Menu");

    jMenu6.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Iconos/city8.png"))); // NOI18N
    jMenu6.setText("Empresa");

    jMenuItem3.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Iconos/buildings8.png"))); // NOI18N
    jMenuItem3.setText("Ver empresas");
    jMenuItem3.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem3ActionPerformed(evt);
          }
        });
    jMenu6.add(jMenuItem3);

    jMenu1.add(jMenu6);

    jMenu4.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Iconos/documents7.png"))); // NOI18N
    jMenu4.setText("Contratos");

    jMenuItem2.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Iconos/write61.png"))); // NOI18N
    jMenuItem2.setText("Contratos");
    jMenuItem2.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem2ActionPerformed(evt);
          }
        });
    jMenu4.add(jMenuItem2);

    jCheckBoxMenuItem1.setSelected(true);
    jCheckBoxMenuItem1.setText("Nuevo Contrato");
    jCheckBoxMenuItem1.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Iconos/pages.png"))); // NOI18N
    jCheckBoxMenuItem1.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jCheckBoxMenuItem1ActionPerformed(evt);
          }
        });
    jMenu4.add(jCheckBoxMenuItem1);

    jMenu1.add(jMenu4);

    jMenu3.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Iconos/multiple25.png"))); // NOI18N
    jMenu3.setText("Usuarios");

    jMenuItem4.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Iconos/group2.png"))); // NOI18N
    jMenuItem4.setText("Ver Usuarios");
    jMenuItem4.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem4ActionPerformed(evt);
          }
        });
    jMenu3.add(jMenuItem4);

    MnewUser.setSelected(true);
    MnewUser.setText("Nuevo Usuario");
    MnewUser.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Iconos/user91.png"))); // NOI18N
    MnewUser.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            MnewUserActionPerformed(evt);
          }
        });
    jMenu3.add(MnewUser);

    jMenu1.add(jMenu3);

    jMenu2.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Iconos/Seguimientos.png"))); // NOI18N
    jMenu2.setText("Seguimientos");

    jMenuItem5.setIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/Iconos/ver Seguimientos.png"))); // NOI18N
    jMenuItem5.setText("Ver Seguimientos");
    jMenuItem5.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem5ActionPerformed(evt);
          }
        });
    jMenu2.add(jMenuItem5);

    jMenu1.add(jMenu2);

    jMenuItem1.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Iconos/close6.png"))); // NOI18N
    jMenuItem1.setText("Salir");
    jMenuItem1.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem1ActionPerformed(evt);
          }
        });
    jMenu1.add(jMenuItem1);

    jMenuBar1.add(jMenu1);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jPanel1,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jPanel1,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                    .addContainerGap()));

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