ArrayList (NetBeans) - Remoção e Pesquisa [Dúvida]

35 respostas
Skull_Drummer

Olá!
Estou fazendo um trabalho de faculdade (interface gráfica no NetBeans), onde crio um cadastro, armazeno em uma arraylist e coloco 2 botões, pesquisar e excluir.
Montei o cadastro, armazenei na arraylist e exibi, porém não consigo fazer esses 2 comandos funcionarem (pesquisa e exclusão). Alguem pode ajudar com a lógica para esses 2 eventos?

Agradeço!

35 Respostas

adolfo_eloy

Poderia passar o código fonte,
ou até mesmo postar o código que é chamado
pelos botões de pesquisar e excluir?

abelgomes

qual o seu criterio de busca?
posta o codigo ai…

Skull_Drummer

Cadastro cadRemovido = (Cadastro) Lista.remove(1); System.out.println("Empresa removida: " + cadRemovido);

O de pesquisar tentei com a mesma lógica, porem pesquisando em posições na lista

abelgomes

nao gafanhoto…

vc faz assim…como vc ta começando vamos usar coisas simples blz…

Cadastro c = new Cadastro();
for(int i = 0;i<lista.size();i++){
 c = (Cadastro) lista.get(i);
  if(c.getNome().toUpperCase().startsWith("qualque coisa".toUpperCase())){
     return c;
      break;
    //agora se vc tiver mais de um que comece com determinada letra, entao ele so pegara o primeiro....ou vc pode colocar todos que comecem com essa letra em uma lista e retornar essa lista...de pois vc trabalha com ela....
  }
}
Skull_Drummer

Certo!

Isso vai ser inserido em uma nova janela de pesquisa e uma nova janela de exclusão, tem algo que diferencie o código em relação a estarem em outras janelas (JFrame)???

Valeu

abelgomes

nao…desde que esssa outra janela tenha os valores que foi desta…

tipo isso de vc colocar esse ArrayList na classe do JFrame não é legal…o ideial seria vc criar uma classe intermediaria pra ficar entra o seu Cadastro e a Janela…entao todas as Janelas chamariam os metodos dessa classe itermediaria…

Skull_Drummer

E como faria pra ver se existe o cadastro?
Usaria o getnome() ou o get_text do que a pessoa digitar na caixa?

abelgomes

isso é logica em…nao fique preguiçoso não meu amigo…

vc pega o texto que o cara digitou e coloca em uma String…

depois vc chama o metodo por exemplo

public Cadastro verSeTem(String _nome){
  //ai entra aquela logica de busca acima citada
}


//e na sua tela fica

String texto = jTextField1.getText();
Cadastro c = Suaclasse.verSeTem(texto)
if(c==null){
  JOptionPane("Nao tem");
}else{
   JOptionPane(" nome é: "+ c.getNome());
}

mais ou menos isso…

agora um aviso de amigo…se o pessoal aqui percerber que vc esta com preguiça de pensar ou pesquisar,vao começar a te colocar na geladeira quanto as suas perguntas…

:wink:

nao me leve a mal…mas ja vi isso acontecer…

Skull_Drummer

Não é preguiça de pensar não, é q nunca tive contato com NetBeans e nem com Interfaces Gráficas. Por isso perguntei se usaria o getnome() ou se usaria o padrão de textbox do netbeans que é o get_text.

Valeu

Skull_Drummer

Clico em pesquisa e ele gera um erro...alguém pode ajudar? :cry:

import java.util.*;
import javax.swing.*;
/*
 * CadastrarNovo.java
 *
 * Created on 14 de Outubro de 2008, 21:54
 */



/**
 *
 * @author  GRUPO
 */
public class CadastrarNovo extends javax.swing.JFrame {

    /** Creates new form CadastrarNovo */
    public CadastrarNovo() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        txt_nome = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txt_idade = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txt_cnpj = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txt_endereco = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txt_cep = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txt_cidade = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        txt_estado = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        txt_atuacao = new javax.swing.JTextField();
        bt_sair = new javax.swing.JButton();
        bt_enviar = new javax.swing.JButton();
        bt_limpar = new javax.swing.JButton();
        bt_consultar = new javax.swing.JButton();
        bt_excluir = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Nome:");

        jLabel2.setText("Fundação da Empresa:");

        txt_idade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_idadeActionPerformed(evt);
            }
        });

        jLabel3.setText("CNPJ(CPF):");

        txt_cnpj.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_cnpjActionPerformed(evt);
            }
        });

        jLabel4.setText("Endereço:");

        jLabel5.setText("CEP:");

        jLabel6.setText("Cidade:");

        jLabel7.setText("Estado:");

        jLabel8.setText("Atuação no Mercado:");

        bt_sair.setText("Sair");
        bt_sair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_sairActionPerformed(evt);
            }
        });

        bt_enviar.setText("Enviar");
        bt_enviar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_enviarActionPerformed(evt);
            }
        });

        bt_limpar.setText("Limpar");
        bt_limpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_limparActionPerformed(evt);
            }
        });

        bt_consultar.setText("Consulta Rápida");
        bt_consultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_consultarActionPerformed(evt);
            }
        });

        bt_excluir.setText("Excluir");

        jLabel9.setText("Nome da Empresa:");

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(txt_cnpj))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txt_nome, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(31, 31, 31)
                                        .addComponent(jLabel2))
                                    .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel5)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txt_cep)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel7)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txt_estado, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(txt_idade, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(txt_endereco, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(bt_enviar)
                                                .addGap(18, 18, 18)
                                                .addComponent(bt_limpar))
                                            .addComponent(txt_atuacao, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(jLabel6)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txt_cidade, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGap(83, 83, 83)
                                        .addComponent(bt_excluir)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 81, Short.MAX_VALUE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(bt_consultar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(bt_sair)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txt_nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(txt_idade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txt_cnpj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(txt_cep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(txt_estado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(txt_endereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(txt_cidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(35, 35, 35)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(txt_atuacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bt_consultar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 58, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bt_sair)
                    .addComponent(bt_enviar)
                    .addComponent(bt_limpar)
                    .addComponent(bt_excluir))
                .addGap(25, 25, 25))
        );

        pack();
    }// </editor-fold>

private void bt_limparActionPerformed(java.awt.event.ActionEvent evt) {                                          

    txt_nome.setText(null);
    txt_idade.setText(null);
    txt_cnpj.setText(null);
    txt_endereco.setText(null);
    txt_cep.setText(null);
    txt_cidade.setText(null);
    txt_estado.setText(null);
    txt_atuacao.setText(null);
    
    // TODO add your handling code here:
}                                         

 ArrayList CadastrarNovo = new ArrayList();
private void bt_enviarActionPerformed(java.awt.event.ActionEvent evt) {                                          

   Cadastro c = new Cadastro(txt_nome.getText(),txt_idade.getText(),txt_cnpj.getText(),txt_endereco.getText(),txt_cep.getText(),txt_cidade.getText(),txt_estado.getText(),txt_atuacao.getText());
  
      String str=c.ToString();        
    CadastrarNovo.add(str);
    
    
for (int i=0; i< CadastrarNovo.size(); i++){
     
		System.out.println(CadastrarNovo.get(i));
                
}
  
}                                         



private void bt_sairActionPerformed(java.awt.event.ActionEvent evt) {                                        

    System.exit(0);
    // TODO add your handling code here:
}                                       

private void txt_cnpjActionPerformed(java.awt.event.ActionEvent evt) {                                         
// TODO add your handling code here:
}                                        

private void txt_idadeActionPerformed(java.awt.event.ActionEvent evt) {                                          
// TODO add your handling code here:
}                                         

private void bt_consultarActionPerformed(java.awt.event.ActionEvent evt) {                                             
     
    Cadastro c = new Cadastro(txt_nome.getText(),txt_idade.getText(),txt_cnpj.getText(),txt_endereco.getText(),txt_cep.getText(),txt_cidade.getText(),txt_estado.getText(),txt_atuacao.getText());
 for(int i = 0;i<CadastrarNovo.size();i++){   
c = (Cadastro) CadastrarNovo.get(i);   
  if(c.getNome().toUpperCase().startsWith("a".toUpperCase())){   
       System.out.println(CadastrarNovo.get(i));
  }
  }

}                                            

private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    
        
                java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CadastrarNovo().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton bt_consultar;
    private javax.swing.JButton bt_enviar;
    private javax.swing.JButton bt_excluir;
    private javax.swing.JButton bt_limpar;
    private javax.swing.JButton bt_sair;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField txt_atuacao;
    private javax.swing.JTextField txt_cep;
    private javax.swing.JTextField txt_cidade;
    private javax.swing.JTextField txt_cnpj;
    private javax.swing.JTextField txt_endereco;
    private javax.swing.JTextField txt_estado;
    private javax.swing.JTextField txt_idade;
    private javax.swing.JTextField txt_nome;
    // End of variables declaration


    
 
 		
		 

        	
}
abelgomes

cade o erro?

Skull_Drummer

Um monte de linha azul…

Com o contains eu conseguiria fazer isso??

abelgomes

olha só…
aqui nessa linha

if(c.getNome().toUpperCase().startsWith(“a”.toUpperCase())){

System.out.println(CadastrarNovo.get(i));

}

}

nao é “a” é o seu texto que o usuario digitou…

e aqui

System.out.println(CadastrarNovo.get(i));

é onde vc adciona o cadastro a um JoptionPane…mas nao o Objeto…e sim os atributos…

se vc vai so colocar no console msmo pra imprimir
entao use assim

System.out.println(CadastrarNovo.get(i).getNome());
e assim por diante…

Skull_Drummer

Coloquei assim:

private void bt_consultarActionPerformed(java.awt.event.ActionEvent evt) {                                             

    Cadastro c = new Cadastro(txt_nome.getText(),txt_idade.getText(),txt_cnpj.getText(),txt_endereco.getText(),txt_cep.getText(),txt_cidade.getText(),txt_estado.getText(),txt_atuacao.getText());   
for(int i = 0;i<CadastrarNovo.size();i++){     
c = (Cadastro) CadastrarNovo.get(i);     
  if(c.getNome().toUpperCase().startsWith("txt_nomemp.getText()".toUpperCase())){     
       System.out.println(CadastrarNovo.get(i).getNome());

E ta dando erro de "Cannot find symbol: method getNome() cannot find symbol: method println :(

abelgomes

vc no pode seguir a risca os codigo q sao dados aqui…aqui sao dados so rumos…

tipo tira essas aspas txt_nomep.getText()

e para dar
System.out.println(CadastrarNovo.get(i).getNome());

tem que fazer o Casting e ai fica assim
System.out.println((Cadastro)CadastrarNovo.get(i).getNome());

e se vc esta com o netbeans entao ele te dar um opcao de coreção disso com o casting…

V ai se funciona…

Skull_Drummer

Fiz sem as aspas:

if(c.getNome().toUpperCase().startsWith(txt_nomemp.getText().toUpperCase())) System.out.println((Cadastro)CadastrarNovo.get(i).getNome());

Fiz o cast pra Cadastro, pra CadastrarNovo, etc…e continua dando o mesmo erro do cannot find symbol…

abelgomes

anexa seu projeto ai pra eu dar uma olhada…

Skull_Drummer

[b]Anexo abaixo.

Trabalho passado na terça pra ser entregue na quinta…isso acaba com os miólos…[/b]

abelgomes

qual a versao do seu netbeans?

procura por esse

GroupLayout.jar

ai no seu pc e posta aqui…

Skull_Drummer

6.1

Skull_Drummer

Procurei dentro do C:\Arquivos de programas\Netbeans e ele não encontrou nada…

abelgomes

vai no pesquisar do windows mesmo…e digita

Skull_Drummer

Nada…não achou nada…

abelgomes

blz…dou meu jeito aqui…espera ai…

Skull_Drummer

Putz, velho…se me der uma força com isso eu ia agradecer mesmo!
só 2 dias pra fazer uma estrutura dessas é f***!

fabim

Skull_Drummer:
Fiz sem as aspas:

if(c.getNome().toUpperCase().startsWith(txt_nomemp.getText().toUpperCase())) System.out.println((Cadastro)CadastrarNovo.get(i).getNome());

Fiz o cast pra Cadastro, pra CadastrarNovo, etc…e continua dando o mesmo erro do cannot find symbol…

Vc esta tentando chamar getNome() em cima de uma referencia de Object… faltam parenteses ali:
Tente conforme abaixo… percebe que eu coloquei parenteses em b[/b]:

if(c.getNome().toUpperCase().startsWith(txt_nomemp.getText().toUpperCase()))    
       System.out.println(((Cadastro)CadastrarNovo.get(i)).getNome());
Skull_Drummer

:cry:mesmo erro;…

abelgomes

Tai meu velho…reveja os metodos get e set…pois estavam mal feitos…compare com o seu antes de sobscrever…dei uma mexida no metodo de incluir e no de buscar… veja la e me diga

abelgomes

eae oque q deu?

Skull_Drummer

Valeu, cara…acho q agora entendi como tinha q ser feito com o object c…

E tipo…pra exclusão eu consigo usar o CadastrarNovo.remove(txt_excluir) ou eu teria que converter isso pra inteiro??

abelgomes

vc teria que fazer uma busca…e só quando encontrar vc remove o Objeto inteiro…
tenta fazer ai…qualquer coisa posta aqui…

Skull_Drummer

Outra coisa…o método TOString não existe mais?
Mandei um Syso e ele me imprimiu um HashCode…

abelgomes

puts é mesmo…vc vai ter que criar denovo… foi mal…

Skull_Drummer

Sem problemas!

Então…o q o usuario digita na caixa é uma string, não? Como a exclusão seria feita?
Usei o esquema CadastraNovo.remove(txt_exc.getText());
E ele me retornou erro dizendo que não reconhecia o parametro informado…

abelgomes

sim, ele vai retornoar erro pq na Lista só tem Cadastro, ou seja…vc nao vai encontrar String lá dentro…entao como fazer…

vc usa a mesma logica do procurar…mas no hora que achar ao inves de vc exibir…

dar um CadastraNovo.remove©;

:wink: sacou?

Criado 16 de outubro de 2008
Ultima resposta 16 de out. de 2008
Respostas 35
Participantes 4