public boolean cadastrar(Atleta a) {
    am = new AtletaModel();

    if (am.checarMatriculaExistente(a.getMatricula()) == true) {

      if (am.checarRgExistente(a.getRg())) {

        if (!"".equals(arquivoImagem)) {
            /*checa se tem imagem.*/

          arquivoImagemCaminho = am.savarImagem(a.getMatricula(), arquivoImagem);
          a.setFoto(arquivoImagemCaminho);
        }

        if (am.cadastrar(a) == false) {
          JOptionPane.showMessageDialog(
              null, "Falha ao gravar.", "Alerta", JOptionPane.ERROR_MESSAGE);
        } else {

          JOptionPane.showMessageDialog(
              null, "Cadastro realizado.", "Alerta", JOptionPane.INFORMATION_MESSAGE);
          atm = (AtletaTableModel) AtletaView.atletaTabela.getModel();
          int count = atm.getRowCount();
          atm.addRow(a.getMatricula(), a.getNome(), a.getRg(), a.getAtivo(), count);
          return true;
        }

      } else {
        JOptionPane.showMessageDialog(null, "RG em uso.", "Alerta", JOptionPane.ERROR_MESSAGE);
        return false;
      }
    } else {
      JOptionPane.showMessageDialog(null, "Matricula em uso.", "Alerta", JOptionPane.ERROR_MESSAGE);
      return false;
    }
    return false;
  }