Estou fazendo um trabalho para a faculdade, onde preciso criar um programa que cadastra pessoas e as exibe em uma lista por ordem alfabetica, a principio o trabalho esta completo, mas esta dando esse erro e nao consigo corrigir.
erros:
at visual.CadastroVis.(CadastroVis.java:30)
at cadastrodepessoas.Principal.main(Principal.java:22)
private void validaCampo(JTextField campo, JTextArea areaMSG, String mensagem){
if (campo.getText().length() == 0){
areaMSG.setText(areaMSG.getText()+mensagem+"\n");
}
}
private void validaPessoa(JTextArea areaMSG){
validaCampo(insereNome, areaMSG, "Nome não preenchido");
validaCampo(insereCpf, areaMSG, "CPF não preenchido");
validaCampo(insereDataDeNascimento, areaMSG, "Data de Nascimento não preenchida");
validaCampo(insereRg, areaMSG, "RG não preenchido");
}
ArrayList Cadastrar = new ArrayList();
private void botaoCadastrarActionPerformed(java.awt.event.ActionEvent evt) {
mensagem.setText("");
validaPessoa(mensagem);
if(mensagem.getText().length() == 0){
Pessoa p = new Pessoa();
String str = p.getNome()+"\n"+p.getCpf()+"\n"+p.getDataDeNascimento()+"\n"+p.getRg()+"\n"+p.getDdd()+"\t"+p.getNumeroDoTelefone();
Cadastrar.add(str);
mensagem.setText(mensagem.getText()+"\nCadastrado(a)\n");
}
}
private void botaoListaDePessoasActionPerformed(java.awt.event.ActionEvent evt) {
Collections.sort(Cadastrar);
for(int i = 0; i < Cadastrar.size(); i++){
mensagem.setText((String) Cadastrar.get(i));
}
}
/**
* @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(CadastroVis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(CadastroVis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(CadastroVis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(CadastroVis.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 CadastroVis().setVisible(true);
}
});
}