package Interface;
import Classes.CadastroDePessoas;
import Classes.Pessoa;
import Classes.PlainDocument;
import java.util.NoSuchElementException;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
/**
*
* @author P Informática
*/
public class JanelaCadastroDePessoas extends javax.swing.JFrame {
CadastroDePessoas cadp = new CadastroDePessoas();
Pessoa p1 = new Pessoa("TESTE", "a", "a", "a", "a", "a", "a", "a");
Pessoa p2 = new Pessoa("GUILHERME", "2a", "2a", "2a", "2a", "2a", "2a", "2a");
public JanelaCadastroDePessoas() {
initComponents();
/* try {
cadp = CadastroDePessoas.class.newInstance();
}
catch (InstantiationException ex) {
Logger.getLogger(JanelaCadastroDePessoas.class.getName()).log(Level.SEVERE, "Erro", ex);
}
catch (IllegalAccessException ex) {
Logger.getLogger(JanelaCadastroDePessoas.class.getName()).log(Level.SEVERE, "Erro", ex);
}*/
}
//AKI CODIGO GERADO PELO NETBEANS
private void btnFecharActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}
private void btnProximoElemActionPerformed(java.awt.event.ActionEvent evt) {
try{
txtNome.setText(cadp.prox().getNome());
txtPosicaoLista.setText(String.valueOf(cadp.getPosicao()+2)+1);
}
catch(NoSuchElementException nsee){
JOptionPane.showMessageDialog(null, "Não há registros na lista!", "ERRO", JOptionPane.ERROR_MESSAGE);
}
catch(IndexOutOfBoundsException iofbe){
JOptionPane.showMessageDialog(null, "Não há proximo registro", "ERRO", JOptionPane.ERROR_MESSAGE);
}
catch(NullPointerException npe){
JOptionPane.showMessageDialog(null, "Não há proximo registro!", "ERRO", JOptionPane.ERROR_MESSAGE);
}
}
private void btnUltimoElemActionPerformed(java.awt.event.ActionEvent evt) {
try{
txtNome.setText(cadp.ultimoDaLista().getNome()); // ALTERAR ISSO
txtPosicaoLista.setText(String.valueOf(cadp.ultimoDaLista()));
}
catch(NoSuchElementException nsee){
JOptionPane.showMessageDialog(null, "Não há registros na lista", "ERRO", JOptionPane.ERROR_MESSAGE);
}
catch(IndexOutOfBoundsException iofbe){
JOptionPane.showMessageDialog(null, "Não há registros", "ERRO", JOptionPane.ERROR_MESSAGE);
}
catch(NullPointerException npe){
JOptionPane.showMessageDialog(null, "Não há mais registros!", "ERRO", JOptionPane.ERROR_MESSAGE);
}
}
private void btnPrimeiroElemActionPerformed(java.awt.event.ActionEvent evt) {
try{
txtNome.setText(cadp.primeiroDaLista().getNome()); // ALTERAR ISSO
txtPosicaoLista.setText(String.valueOf(cadp.primeiroDaLista()));
}
catch(NoSuchElementException nsee){
JOptionPane.showMessageDialog(null, "Não há registros na lista", "ERRO", JOptionPane.ERROR_MESSAGE);
}
catch(IndexOutOfBoundsException iofbe){
JOptionPane.showMessageDialog(null, "Não há registros", "ERRO", JOptionPane.ERROR_MESSAGE);
}
catch(NullPointerException npe){
JOptionPane.showMessageDialog(null, "Não há registros!", "ERRO", JOptionPane.ERROR_MESSAGE);
}
}
private void btnAnteriorElemActionPerformed(java.awt.event.ActionEvent evt) {
try{
txtNome.setText(cadp.primeiroDaLista().getNome()); // ALTERAR ISSO
txtPosicaoLista.setText(String.valueOf((cadp.getPosicao()+2)-1));
}
catch(NoSuchElementException nsee){
JOptionPane.showMessageDialog(null, "Não há registros na lista", "ERRO", JOptionPane.ERROR_MESSAGE);
}
catch(IndexOutOfBoundsException iofbe){
JOptionPane.showMessageDialog(null, "Não há registro anterior", "ERRO", JOptionPane.ERROR_MESSAGE);
}
catch(NullPointerException npe){
JOptionPane.showMessageDialog(null, "Não há registro anterior!", "ERRO", JOptionPane.ERROR_MESSAGE);
}
}
private void btnIrParaActionPerformed(java.awt.event.ActionEvent evt) {
try{
cadp.getLista().get(Integer.parseInt(txtIrPara.getText().trim()));
}
catch(IndexOutOfBoundsException iofbe){
JOptionPane.showMessageDialog(null, "Não há elementos na posição selecionada", "ERRO", JOptionPane.ERROR_MESSAGE);
}
catch(NumberFormatException nfe){
JOptionPane.showMessageDialog(null, "Este campo deve ser preenchido com números e sem espaços entre eles", "ERRO", JOptionPane.WARNING_MESSAGE);
}
finally{txtIrPara.setText("");}
}
private void btnAddNovaPessoaActionPerformed(java.awt.event.ActionEvent evt) {
try{
if(txtNome.getText().trim().equals("") ){ //EM CONSTRUÇÃO
}
txtApelido.setText("");
txtBairro.setText("");
txtCep.setText("");
txtCidade.setText("");
txtEmailGeral.setText("");
txtEndereco.setText("");
txtFax.setText("");
txtHomePage.setText("");
txtIrPara.setText("");
txtNome.setText("");
txtPosicaoLista.setText("");
txtTelefone.setText("");
txtUF.setText("");
}
finally{
}
}
public CadastroDePessoas getCdp(){
return cadp;
}
public JTextField getTxtNome(){
return txtNome;
}
public JTextField getTxtApelido(){
return txtApelido;
}
public JTextField getTxtBairro(){
return txtBairro;
}
public JTextField getTxtCep(){
return txtCep;
}
public JTextField getTxtCidade(){
return txtCidade;
}
public JTextField getTxtEmailGeral(){
return txtEmailGeral;
}
public JTextField getTxtEndereco(){
return txtEndereco;
}
public JTextField getTxtFax(){
return txtFax;
}
public JTextField getTxtUf(){
return txtUF;
}
public JTextField getTxtTelefone(){
return txtTelefone;
}
public JTextField getTxtHomePage(){
return txtHomePage;
}
public JTextField getTxtPosicaoLista(){
return txtPosicaoLista;
}
//AKI VARIAVEIS GERADAS PELO NETBEANS
}
PS.: instanciei daquelas duas maneiras a lista para testar se estava chamando a mesma! (parece q não) :/