Tela de pedidos (ComboBox) Swing

Pessoal, antes de mais nada peço desculpas, digamos que não sei nada de java. estou fazendo um “sisteminha” de vendas. onde já tenho pronto as telas de:

cadastro de clientes;
cadastro de produtos;
login.

o que está me faltando agora é criar a tela de pedidos. Estou empacado na seguinte parte. Já tenho a tela pronta, onde coloquei 2 comboBox um para listar os clientes e outro para listar o produto e um text para informar a quantidade do item escolhido. Não estou conseguindo fazer a com que o combo busque no banco o resultado dos campos.

segue código(aproveitei o código de outra classe que já está funcionando)

[code]
package ProjetoV1.View;
import ProjetoV1.Controller.Dvd;
import ProjetoV1.Model.DvdDao;

import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

/**
*

  • @author Rodrigo Campos
    */
    public class LojaPedido extends javax.swing.JInternalFrame {

    DefaultTableModel tmContato = new DefaultTableModel (null, new String []{“Num Venda”,“Cod Cliente”,“Produto”,“Quantidade”,“Preço”,“Data”});
    List contatos;
    ListSelectionModel lsmContato;

    /**

    • Creates new form LojaAcervoDvds
      */
      public LojaPedido() {
      initComponents();
      desabilitaDados();
      }

    @SuppressWarnings(“unchecked”)
    //
    private void initComponents() {

     jPanel2 = new javax.swing.JPanel();
     jScrollPane1 = new javax.swing.JScrollPane();
     jTTabela = new javax.swing.JTable();
     jLCliente = new javax.swing.JLabel();
     jCCliente = new javax.swing.JComboBox();
     jCProdutos = new javax.swing.JComboBox();
     jLCliente1 = new javax.swing.JLabel();
     jPanel1 = new javax.swing.JPanel();
     jBPedido = new javax.swing.JButton();
     jBAlterar = new javax.swing.JButton();
     jBExcluir = new javax.swing.JButton();
     jBSalvar = new javax.swing.JButton();
     jBSair = new javax.swing.JButton();
     jTQuantidade = new javax.swing.JTextField();
     jLCliente2 = new javax.swing.JLabel();
    
     setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
     setTitle("Pedido de Compras");
    
     jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("| ITENS DO PEDIDO |"));
    
     jTTabela.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
     jTTabela.setModel(tmContato);
     jTTabela.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
     desabilitaDados();
     jTTabela.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     lsmContato = jTTabela.getSelectionModel();
     lsmContato.addListSelectionListener(new ListSelectionListener() {
         public void valueChanged(ListSelectionEvent e) {
             if(! e.getValueIsAdjusting()){
                 jTTabelaLinhaSelecionada(jTTabela);
             }
         }
     });
     jScrollPane1.setViewportView(jTTabela);
    
     javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
     jPanel2.setLayout(jPanel2Layout);
     jPanel2Layout.setHorizontalGroup(
         jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
         .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
     );
     jPanel2Layout.setVerticalGroup(
         jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
         .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
     );
    
     jLCliente.setFont(new java.awt.Font("Tahoma", 1, 11));
     jLCliente.setText("Cliente:");
    
     jCCliente.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
     jCCliente.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
             jCClienteActionPerformed(evt);
         }
     });
    
     jCProdutos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    
     jLCliente1.setFont(new java.awt.Font("Tahoma", 1, 11));
     jLCliente1.setText("Produto:");
    
     jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("| MENU |"));
     jPanel1.setAutoscrolls(true);
    
     jBPedido.setFont(new java.awt.Font("Tahoma", 0, 10));
     jBPedido.setToolTipText("Clique aqui para incluir um novo Título no acervo.");
     jBPedido.setLabel("PEDIDO");
     jBPedido.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
             jBPedidoActionPerformed(evt);
         }
     });
    
     jBAlterar.setFont(new java.awt.Font("Tahoma", 0, 10));
     jBAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ProjetoV1/View/img/pesquisar_10.fw.png"))); // NOI18N
     jBAlterar.setText("ALTERAR");
     jBAlterar.setToolTipText("Clique aqui para efetuar aterações no dados cadastrados.");
     jBAlterar.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
             jBAlterarActionPerformed(evt);
         }
     });
    
     jBExcluir.setFont(new java.awt.Font("Tahoma", 0, 10));
     jBExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ProjetoV1/View/img/excluir_10.fw.png"))); // NOI18N
     jBExcluir.setText("EXCLUIR");
     jBExcluir.setToolTipText("Clique aqui para efetuar a exclusão de um Título.");
     jBExcluir.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
             jBExcluirActionPerformed(evt);
         }
     });
    
     jBSalvar.setFont(new java.awt.Font("Tahoma", 0, 10));
     jBSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ProjetoV1/View/img/salvar_10.fw.png"))); // NOI18N
     jBSalvar.setText("SALVAR");
     jBSalvar.setToolTipText("Clique aqui para salvar os dados inseridos ou alterdos.");
     jBSalvar.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
             jBSalvarActionPerformed(evt);
         }
     });
    
     jBSair.setFont(new java.awt.Font("Tahoma", 0, 10));
     jBSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ProjetoV1/View/img/sair_10.fw.png"))); // NOI18N
     jBSair.setText("SAIR");
     jBSair.setToolTipText("Clique aqui para sair do programa.");
     jBSair.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
             jBSairActionPerformed(evt);
         }
     });
    
     javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
     jPanel1.setLayout(jPanel1Layout);
     jPanel1Layout.setHorizontalGroup(
         jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
         .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
             .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
             .addComponent(jBAlterar, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
             .addComponent(jBPedido)
             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
             .addComponent(jBExcluir)
             .addGap(18, 18, 18)
             .addComponent(jBSalvar)
             .addGap(18, 18, 18)
             .addComponent(jBSair, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
             .addGap(86, 86, 86))
     );
     jPanel1Layout.setVerticalGroup(
         jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
         .addGroup(jPanel1Layout.createSequentialGroup()
             .addContainerGap()
             .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                 .addComponent(jBSair, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
                 .addComponent(jBSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addComponent(jBExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addComponent(jBPedido, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
                 .addComponent(jBAlterar, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE))
             .addContainerGap())
     );
    
     jLCliente2.setFont(new java.awt.Font("Tahoma", 1, 11));
     jLCliente2.setText("Quantidade:");
    
     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(82, 82, 82)
                     .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 527, javax.swing.GroupLayout.PREFERRED_SIZE))
                 .addGroup(layout.createSequentialGroup()
                     .addGap(39, 39, 39)
                     .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                         .addComponent(jLCliente)
                         .addComponent(jCCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 534, javax.swing.GroupLayout.PREFERRED_SIZE)
                         .addGroup(layout.createSequentialGroup()
                             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                 .addComponent(jCProdutos, javax.swing.GroupLayout.PREFERRED_SIZE, 420, javax.swing.GroupLayout.PREFERRED_SIZE)
                                 .addComponent(jLCliente1))
                             .addGap(22, 22, 22)
                             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                 .addComponent(jLCliente2)
                                 .addComponent(jTQuantidade, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))))))
             .addGap(91, 91, 91))
         .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
             .addContainerGap()
             .addComponent(jPanel2, 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.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
             .addGap(19, 19, 19)
             .addComponent(jLCliente)
             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
             .addComponent(jCCliente, 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(jLCliente1)
                 .addComponent(jLCliente2))
             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                 .addComponent(jCProdutos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addComponent(jTQuantidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
             .addGap(53, 53, 53)
             .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
             .addContainerGap(38, Short.MAX_VALUE))
     );
    
     jPanel2.getAccessibleContext().setAccessibleName("| TELA DE PEDIDOS |");
    
     pack();
    

    }//
    //BOTÃO SAIR;
    private void jBSairActionPerformed(java.awt.event.ActionEvent evt) {
    System.exit(0);
    }

//BOTÃO NOVO:CRIA UM NOVO ITEM NO BANCO;
private void jBPedidoActionPerformed(java.awt.event.ActionEvent evt) {
habilitaDados();
jCCliente.setSelectedIndex(2);
jCProdutos.setSelectedIndex(3);
jTQuantidade.setText("");

}                                        

//DESABILITA A EDIÇAO DOS CAMPOS QUE MOSTRAM OS RESULTADOS;
public void desabilitaDados() {
jCCliente.setEditable(false);
jCProdutos.setEditable(false);
jTQuantidade.setEditable(false);

}

//HABILITA A EDIÇAO DOS CAMPOS QUE MOSTRADOS NO RESULTADO SA PESQUISA;
public void habilitaDados() {
jCCliente.setEditable(true);
jCProdutos.setEditable(true);
jTQuantidade.setEditable(true);

}

//METODO PRA SELECIONAR LINHA
public void jTTabelaLinhaSelecionada(JTable tabela) {
if (jTTabela.getSelectedRow() != -1) {
habilitaDados();
jCCliente.setText(String.valueOf(contatos.get(tabela.getSelectedRow()).getjCCliente()));
jCProdutos.setText(contatos.get(tabela.getSelectedRow()).getjCProdutos());
jTQuantidade.setText(contatos.get(tabela.getSelectedRow()).getjTQuantidade());

    } else {
        jCCliente.setText("");
        jCProdutos.setText("");
        jTQuantidade.setText("");
       
    }
}

//VERIFICA DADOS,SALVA E MOSTRA LISTA ALTERADA;
private void jBSalvarActionPerformed(java.awt.event.ActionEvent evt) {
if (verificaDados()) {
cadastro();
try {
listarContatos();
} catch (SQLException ex) {
Logger.getLogger(LojaPedido.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
JOptionPane.showMessageDialog(null, “Não foi possivel completar o cadastro\n”);
}

}

//RETORNA A LISTA DO BANCO;
public void listarContatos() throws SQLException{
DvdDao dao = new DvdDao();
contatos = dao.getLista("%" + jTCliente.getText() + “%”);
mostraPesquisa(contatos);
}

//METODO DE CADASTRO DE UM ITEM;
public void cadastro() {
try {
Dvd c1 = new Dvd();
c1.setTitulo(jTTitulo.getSelectedIndex());
c1.setAutor(jTAutor.getText());
c1.setPreco(jTPreco.getText());
c1.setGenero(jTGenero.getText());
c1.setEstoque(jTEstoque.getText());
c1.setLancamento(jTLancamento.getText());
DvdDao dao = new DvdDao();
dao.adiciona(c1);
JOptionPane.showMessageDialog(null, “Dado adicionado ao banco!”);

    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, "Não foi possivel completar o cadastro\n"+ex);
    }
}                                        


private void jBExcluirActionPerformed(java.awt.event.ActionEvent evt) {                                          
    try {
       excluirContato();
       listarContatos();
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, "Erro no Botão excluir"+ex);
    }
}                                         

//BOTÃO ALTERAR:ALTERA O ITEM SELECIONADO;
private void jBAlterarActionPerformed(java.awt.event.ActionEvent evt) {
try {
alteraContato();
listarContatos();
desabilitaDados();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, “Problema no jBAlterar \n” + ex);
}
}

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

//METODO DE PESQUISA ATRAVES DO ENTER;
//EXCLUI UM COTATO;
public void excluirContato() throws SQLException {
if (verificaCampos()== true){
int resp = JOptionPane.showConfirmDialog(this, “Deseja realmente excluir este Item?”,
“Confirmacao”, JOptionPane.YES_NO_OPTION);
if (resp == JOptionPane.YES_NO_OPTION) {
DvdDao dao = new DvdDao();
dao.remove(contatos.get(jTTabela.getSelectedRow()));
mostraPesquisa(contatos);
}
}
}

/**
* @param args the command line arguments
/
public static void main(String args[]) {
/
Set the Nimbus look and feel /
//
/
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(LojaPedido.class
                .getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(LojaPedido.class
                .getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(LojaPedido.class
                .getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(LojaPedido.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 LojaPedido().setVisible(true);
        }
    });
}
// Variables declaration - do not modify                     
private javax.swing.JButton jBAlterar;
private javax.swing.JButton jBExcluir;
private javax.swing.JButton jBPedido;
private javax.swing.JButton jBSair;
private javax.swing.JButton jBSalvar;
private javax.swing.JComboBox jCCliente;
private javax.swing.JComboBox jCProdutos;
private javax.swing.JLabel jLCliente;
private javax.swing.JLabel jLCliente1;
private javax.swing.JLabel jLCliente2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField jTQuantidade;
private javax.swing.JTable jTTabela;
// End of variables declaration                   

//MOSTRA OS ITENS DO BANCO NA TABELA;
private void mostraPesquisa(List contatos) {
while (tmContato.getRowCount()>0){
tmContato.removeRow(0);
}
if (contatos.isEmpty()) {
JOptionPane.showMessageDialog(null, “Nenhum Item Encontrado!”);
} else {
String[] linha = new String[]{null, null, null, null, null};
for (int i = 0; i < contatos.size(); i++) {
tmContato.addRow(linha);
tmContato.setValueAt(contatos.get(i).getCodigo(),i, 0);
tmContato.setValueAt(contatos.get(i).getTitulo(),i, 1);
tmContato.setValueAt(contatos.get(i).getAutor(),i, 2);
tmContato.setValueAt(contatos.get(i).getPreco(),i, 3);
tmContato.setValueAt(contatos.get(i).getGenero(),i, 4);
tmContato.setValueAt(contatos.get(i).getEstoque(),i, 5);
tmContato.setValueAt(contatos.get(i).getLancamento(),i, 6);
}
}
}

//ALTERAR PEDIDO ;
private void alteraContato() throws SQLException {
if (jTTabela.getSelectedRow() != -1) {
if (verificaDados()) {
Dvd c1 = new Dvd();
DvdDao dao = new DvdDao();
c1.setCodigo(Long.valueOf(jTCodigo.getText()));
c1.setTitulo(jTTitulo.getText());
c1.setAutor(jTAutor.getText());
c1.setPreco(jTPreco.getText());
c1.setGenero(jTGenero.getText());
c1.setEstoque(jTEstoque.getText());
c1.setLancamento(jTLancamento.getText());

            dao.altera(c1);
            JOptionPane.showMessageDialog(null, "Item Alterado com Sucesso!");
        }

     
    }
}

}[/code]

é mais ou menos isso aqui.

public DefaultComboBoxModel getListaClientes() { DefaultComboBoxModel model = new DefaultComboBoxModel(); try{ PreparedStatement pstm = this.getConexion().prepareStatement("SELECT * FROM clientes "); ResultSet res = pstm.executeQuery(); while(res.next()){ model.addElement( res.getString( "id" ) + " - " + res.getString( "nome" ) ); } res.close(); }catch(SQLException e){ System.err.println( e.getMessage() ); } return model; }

[quote=andrebocao]é mais ou menos isso aqui.

public DefaultComboBoxModel getListaClientes() { DefaultComboBoxModel model = new DefaultComboBoxModel(); try{ PreparedStatement pstm = this.getConexion().prepareStatement("SELECT * FROM clientes "); ResultSet res = pstm.executeQuery(); while(res.next()){ model.addElement( res.getString( "id" ) + " - " + res.getString( "nome" ) ); } res.close(); }catch(SQLException e){ System.err.println( e.getMessage() ); } return model; }[/quote]

Prezado André, muito obrigado pelo retorno. esse método que colocaste é referente a classe PedidosDao, fiz o projeto no padrão MVC. O código em questão que postei é referente a minha classe View onde vou adicionar/alterar/excluir os pedidos.
Será que pode me ajudar nisso também?

Já fiz toda CRUD da parte de cadastros de cliente e produtos, está faltando apenas isso para concluir.

Desde já obrigado!!!

Rodrigo Campos

rodrigocpoa,

Não é um bom modo colocar um ComboBox para listar seus clientes ou produtos. Caso seu sistema cresça fica inviável listar esses dados. Com cerca de 50 produtos/clientes já ficaria difícil a visualização desses dados.

Outro ponto importante, como vc retorna seu dados do Dao? Vc retorna os objetos? Seria bom vc escrever seu componente ComboBox para exibir esses dados.

Seria mais interessante vc implementar um JTextField com Listeners para tratar a busca de seus clientes/produtos. Nos meus sistemas faço dessa forma e assim vc pode ter milhares de registros sem que isso prejudique a visualização e a performace.

[quote=HenriqueBR]rodrigocpoa,

Não é um bom modo colocar um ComboBox para listar seus clientes ou produtos. Caso seu sistema cresça fica inviável listar esses dados. Com cerca de 50 produtos/clientes já ficaria difícil a visualização desses dados.

Outro ponto importante, como vc retorna seu dados do Dao? Vc retorna os objetos? Seria bom vc escrever seu componente ComboBox para exibir esses dados.

Seria mais interessante vc implementar um JTextField com Listeners para tratar a busca de seus clientes/produtos. Nos meus sistemas faço dessa forma e assim vc pode ter milhares de registros sem que isso prejudique a visualização e a performace.[/quote]

Boa tarde Henrique, pra falar a verdade pensei nisso, no entanto estou optando pelo mais simples, como se trata de um trabalho para faculdade não estou levando em consideração o crescimento do sistema. Como mencionei, cheguei onde cheguei aos trancos e barrancos e estou empacado nessa parte do sistema.
Poderia me ajudar ou me enviar um exemplo de como proceder nesse caso?

A ideia dessa classe é pesquisar clientes e produtos e adicionar em um tabela um pedido de venda mostrando o total de itens e total em R$. Parece simples falando mas quando chego para implementar não saio da estaca zero.

Rodrigo campos