Ajuda combo box

pessoal estou com um sério problema.

meu professor mando fazer um sistema que quando cadastra o funcionário ele atualiza a jlist q está ao lado e tem q ficar no combo box o departamento selecionado.

tbm quando atualiza o departamento ele já atualiza o conteúdo da combo box

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CadFuncionario.java
 *
 * Created on 15/03/2012, 13:52:52
 */
package gui;

import daoList.DepartamentoDAO;
import daoList.FuncionarioDAO;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import modelo.Departamento;
import modelo.Funcionario;

/**
 *
 * @author Felipe
 */
public class CadFuncionario extends javax.swing.JDialog {

    private FuncionarioDAO daoFunc;
    private DepartamentoDAO daoDpto;
    /** Creates new form CadFuncionario */
    public CadFuncionario(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        daoFunc = new FuncionarioDAO();
        daoDpto = new DepartamentoDAO();
        povoarJList(daoFunc);
        povoarJcomboBox(daoDpto);
    }

    /** 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() {

        jlblIdFuncionario = new javax.swing.JLabel();
        jtxtIdFuncionario = new javax.swing.JTextField();
        jbtnPesquisar = new javax.swing.JButton();
        jlblNomeFuncionario = new javax.swing.JLabel();
        jtxtNomeFuncionario = new javax.swing.JTextField();
        jlblEmail = new javax.swing.JLabel();
        jtxtEmail = new javax.swing.JTextField();
        JlblLogin = new javax.swing.JLabel();
        jtxtLogin = new javax.swing.JTextField();
        jlblSenha = new javax.swing.JLabel();
        jtxtSenha = new javax.swing.JTextField();
        jlblDepartamento = new javax.swing.JLabel();
        jComboBoxDepartamento = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jlstFuncionariosCadastrados = new javax.swing.JList();
        jlblListaFuncionarios = new javax.swing.JLabel();
        jbtnSalvar = new javax.swing.JToggleButton();
        jbtnExcluir = new javax.swing.JToggleButton();
        jbtnLimpar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Cadastro Funcionario");
        setResizable(false);

        jlblIdFuncionario.setText("Id");

        jbtnPesquisar.setText("Pesquisar");
        jbtnPesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnPesquisarActionPerformed(evt);
            }
        });

        jlblNomeFuncionario.setText("Nome");

        jlblEmail.setText("E-mail");

        JlblLogin.setText("Login");

        jlblSenha.setText("Senha");

        jlblDepartamento.setText("Departamento");

        jlstFuncionariosCadastrados.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jlstFuncionariosCadastradosMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jlstFuncionariosCadastrados);

        jlblListaFuncionarios.setText("Funcionarios Cadastrados");

        jbtnSalvar.setText("Salvar");
        jbtnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnSalvarActionPerformed(evt);
            }
        });

        jbtnExcluir.setText("Excluir");
        jbtnExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnExcluirActionPerformed(evt);
            }
        });

        jbtnLimpar.setText("Limpar");
        jbtnLimpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnLimparActionPerformed(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()
                .addGap(19, 19, 19)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbtnSalvar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtnExcluir)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtnLimpar))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlblDepartamento)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jlblEmail)
                                .addComponent(jlblNomeFuncionario)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jtxtIdFuncionario, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(jbtnPesquisar))
                                .addComponent(jlblIdFuncionario)
                                .addComponent(jtxtNomeFuncionario, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                                .addComponent(jtxtEmail))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jComboBoxDepartamento, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jtxtLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(JlblLogin))
                                    .addGap(18, 18, 18)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jtxtSenha, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jlblSenha)))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jlblListaFuncionarios))))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlblIdFuncionario)
                    .addComponent(jlblListaFuncionarios))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxtIdFuncionario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jbtnPesquisar))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlblNomeFuncionario)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtNomeFuncionario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlblEmail)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtEmail, 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.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(JlblLogin)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtxtLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jlblSenha)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtxtSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlblDepartamento)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxDepartamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 20, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbtnSalvar)
                            .addComponent(jbtnExcluir)
                            .addComponent(jbtnLimpar))
                        .addGap(23, 23, 23))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
                        .addGap(18, 18, 18))))
        );

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

    private void jbtnLimparActionPerformed(java.awt.event.ActionEvent evt) {                                           
        limpar();
    }                                          

    private void jbtnSalvarActionPerformed(java.awt.event.ActionEvent evt) {                                           
       Funcionario func = new Funcionario();
        String msg = "";
        try {
            func.setId(Integer.parseInt(jtxtIdFuncionario.getText())); //converte o conteudo do campo ID para integer
            func.setNome(jtxtNomeFuncionario.getText().toUpperCase()); //converte o conteudo do campo Nome para String
            func.setEmail(jtxtEmail.getText().toUpperCase());
            func.setLogin(jtxtLogin.getText().toUpperCase());
            func.setSenha(jtxtSenha.getText().toUpperCase());
            //func.setDepartamento(); falta como q salva o departamento do funcionario
            msg = daoFunc.salvar(func);
            limpar();
            JOptionPane.showMessageDialog(rootPane, msg);

            jtxtIdFuncionario.setText("" + func.getNome());

        } catch (NumberFormatException ex) {
            msg = "Informe um número válido para o departamento";
            JOptionPane.showMessageDialog(rootPane, msg);
        }
        povoarJList(daoFunc);
        povoarJcomboBox(daoDpto);
        limpar();
    }                                          

    private void jbtnExcluirActionPerformed(java.awt.event.ActionEvent evt) {                                            
        Integer id = Integer.parseInt(jtxtIdFuncionario.getText());
        Funcionario func = daoFunc.pesquisarPorID(id);
        String msg = daoFunc.excluir(func);
        JOptionPane.showMessageDialog(rootPane, msg);
        limpar();
        
    }                                           

    private void jbtnPesquisarActionPerformed(java.awt.event.ActionEvent evt) {                                              
        
        try {

            Integer id = Integer.parseInt(jtxtIdFuncionario.getText()); // converte a strig q está digitando no campo e convertendo para integer
            Funcionario func = daoFunc.pesquisarPorID(id);
            if (func != null) {
                preencherTela(func);
            }
        } catch (NumberFormatException ex) {
            String msg = "Informe um número válido para o departamento";
            JOptionPane.showMessageDialog(rootPane, msg);
            limpar();
        }
    }                                             

    private void jlstFuncionariosCadastradosMouseClicked(java.awt.event.MouseEvent evt) {                                                         
       if (evt.getClickCount() >= 2) {
            String pesquisa = jlstFuncionariosCadastrados.getSelectedValue().toString();
            String[] array = pesquisa.split("-"); // divide em varias array a string
            Funcionario func = daoFunc.pesquisarPorID(Integer.parseInt(array[0]));
            preencherTela(func);
        }
    }                                                        

    /**
     * @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(CadFuncionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadFuncionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadFuncionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadFuncionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                CadFuncionario dialog = new CadFuncionario(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JLabel JlblLogin;
    private javax.swing.JComboBox jComboBoxDepartamento;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToggleButton jbtnExcluir;
    private javax.swing.JButton jbtnLimpar;
    private javax.swing.JButton jbtnPesquisar;
    private javax.swing.JToggleButton jbtnSalvar;
    private javax.swing.JLabel jlblDepartamento;
    private javax.swing.JLabel jlblEmail;
    private javax.swing.JLabel jlblIdFuncionario;
    private javax.swing.JLabel jlblListaFuncionarios;
    private javax.swing.JLabel jlblNomeFuncionario;
    private javax.swing.JLabel jlblSenha;
    private javax.swing.JList jlstFuncionariosCadastrados;
    private javax.swing.JTextField jtxtEmail;
    private javax.swing.JTextField jtxtIdFuncionario;
    private javax.swing.JTextField jtxtLogin;
    private javax.swing.JTextField jtxtNomeFuncionario;
    private javax.swing.JTextField jtxtSenha;
    // End of variables declaration                   

    private void limpar() {
        jtxtIdFuncionario.setText("");
        jtxtNomeFuncionario.setText("");
        jtxtEmail.setText("");
        jtxtLogin.setText("");
        jtxtSenha.setText("");
    }

    private void povoarJList(FuncionarioDAO daoFunc) {
        
        DefaultListModel modelo = new DefaultListModel();
        List<Funcionario> listaFunc = daoFunc.getBancoFuncionario();
        jlstFuncionariosCadastrados.setModel(modelo);
        for (Funcionario func : listaFunc) {
            modelo.addElement(func.getId() + "-" + func.getNome());
        }
    }

    private void povoarJcomboBox (DepartamentoDAO daoDpto)
    {
        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
        List <Departamento> listaDpto = daoDpto.getBanco();
        jComboBoxDepartamento.setModel(modelo);
        for (Departamento dpto : listaDpto){
            modelo.addElement(dpto.getNome());
        }
    }

    private void preencherTela(Funcionario func) {
        jtxtIdFuncionario.setText(func.getId() + "");
        jtxtNomeFuncionario.setText(func.getNome().toUpperCase());
        jtxtEmail.setText(func.getEmail().toUpperCase());
        jtxtLogin.setText(func.getLogin());
        jtxtSenha.setText(func.getSenha());
        //jComboBoxDepartamento. como que resgasta o valor da combo box q representa o funcionario.
    }
    
    
    }

Departamento

[code]/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */

/*

  • CadDepartamento.java
  • Created on 05/03/2012, 20:07:06
    */
    package gui;

import daoList.DepartamentoDAO;
import java.lang.NumberFormatException;
import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import modelo.Departamento;

/**
*

  • @author Administrador
    */
    public class CadDepartamento extends javax.swing.JDialog {

    private DepartamentoDAO daoDepto; // criao o objeto para o banco, no caso a array

    /** Creates new form CadDepartamento */
    public CadDepartamento(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    daoDepto = new DepartamentoDAO(); // coloca dentro do construtor!
    initComponents();
    povoarJList(daoDepto);

    }

    /** 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”)
      //
      private void initComponents() {

      jlblID = new javax.swing.JLabel();
      jtxtID = new javax.swing.JTextField();
      jlblNome = new javax.swing.JLabel();
      jtxtNome = new javax.swing.JTextField();
      jbtnPesquisar = new javax.swing.JButton();
      jbtnSalvar = new javax.swing.JButton();
      jbtnExcluir = new javax.swing.JButton();
      jbtnLimpar = new javax.swing.JButton();
      jScrollPane1 = new javax.swing.JScrollPane();
      jlstDepartamento = new javax.swing.JList();

      setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
      setTitle(“Cadastro de Departamento”);
      setResizable(false);

      jlblID.setText(“Número :”);

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

      jlblNome.setText(“Departamento :”);

      jbtnPesquisar.setText(“Pesquisar”);
      jbtnPesquisar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jbtnPesquisarActionPerformed(evt);
      }
      });

      jbtnSalvar.setText(“Salvar”);
      jbtnSalvar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jbtnSalvarActionPerformed(evt);
      }
      });

      jbtnExcluir.setText(“Excluir”);
      jbtnExcluir.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jbtnExcluirActionPerformed(evt);
      }
      });

      jbtnLimpar.setText(“Limpar”);
      jbtnLimpar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jbtnLimparActionPerformed(evt);
      }
      });

      jlstDepartamento.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
      jlstDepartamentoMouseClicked(evt);
      }
      });
      jScrollPane1.setViewportView(jlstDepartamento);

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addGap(27, 27, 27)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jlblID, javax.swing.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)
      .addGroup(layout.createSequentialGroup()
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
      .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
      .addComponent(jbtnSalvar)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
      .addComponent(jbtnExcluir)
      .addGap(11, 11, 11))
      .addComponent(jlblNome, javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jtxtNome, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
      .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
      .addComponent(jtxtID, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addGap(18, 18, 18)
      .addComponent(jbtnPesquisar, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)))
      .addGap(33, 33, 33)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addComponent(jbtnLimpar))
      .addGap(18, 18, 18))))
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addGap(20, 20, 20)
      .addComponent(jlblID)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
      .addGroup(layout.createSequentialGroup()
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
      .addComponent(jtxtID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addComponent(jbtnPesquisar))
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(jlblNome)
      .addGap(11, 11, 11)
      .addComponent(jtxtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
      .addComponent(jScrollPane1, 0, 0, Short.MAX_VALUE))
      .addGap(18, 18, 18)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jbtnLimpar)
      .addComponent(jbtnSalvar)
      .addComponent(jbtnExcluir))
      .addGap(48, 48, 48))
      );

      pack();
      }//

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

    private void jbtnLimparActionPerformed(java.awt.event.ActionEvent evt) {
    Limpar();
    }

    private void jbtnSalvarActionPerformed(java.awt.event.ActionEvent evt) {
    Departamento depto = new Departamento();
    String msg = “”;
    try {
    depto.setId(Integer.parseInt(jtxtID.getText())); //converte o conteudo do campo ID para integer
    depto.setNome(jtxtNome.getText().toUpperCase()); //converte o conteudo do campo Nome para String
    msg = daoDepto.salvar(depto);
    Limpar();
    JOptionPane.showMessageDialog(rootPane, msg);

         jtxtNome.setText("" + depto.getNome());
    
     } catch (NumberFormatException ex) {
         msg = "Informe um número válido para o departamento";
         JOptionPane.showMessageDialog(rootPane, msg);
     }
     povoarJList(daoDepto);
    

    }

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

     try {
    
         Integer id = Integer.parseInt(jtxtID.getText()); // converte a strig q está digitando no campo e convertendo para integer
         Departamento dpto = daoDepto.pesquisarPorId(id);
         if (dpto != null) {
             preencherTela(dpto);
         }
     } catch (NumberFormatException ex) {
         String msg = "Informe um número válido para o departamento";
         JOptionPane.showMessageDialog(rootPane, msg);
         Limpar();
     }
    

    }

    private void jbtnExcluirActionPerformed(java.awt.event.ActionEvent evt) {
    Integer id = Integer.parseInt(jtxtID.getText());
    Departamento dpto = daoDepto.pesquisarPorId(id);
    String msg = daoDepto.excluir(dpto);
    JOptionPane.showMessageDialog(rootPane, msg);
    Limpar();
    povoarJList(daoDepto);
    }

    private void jlstDepartamentoMouseClicked(java.awt.event.MouseEvent evt) {
    if (evt.getClickCount() >= 2) {
    String pesquisa = jlstDepartamento.getSelectedValue().toString();
    String[] array = pesquisa.split("-"); // divide em varias array a string
    Departamento dpto = daoDepto.pesquisarPorId(Integer.parseInt(array[0]));
    preencherTela(dpto);
    }
    }

    /**

    • @param args the command line arguments
      */
      public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {

       public void run() {
           CadDepartamento dialog = new CadDepartamento(new javax.swing.JFrame(), true);
           dialog.addWindowListener(new java.awt.event.WindowAdapter() {
      
               public void windowClosing(java.awt.event.WindowEvent e) {
                   System.exit(0);
               }
           });
           dialog.setVisible(true);
       }
      

      });
      }
      // Variables declaration - do not modify
      private javax.swing.JScrollPane jScrollPane1;
      private javax.swing.JButton jbtnExcluir;
      private javax.swing.JButton jbtnLimpar;
      private javax.swing.JButton jbtnPesquisar;
      private javax.swing.JButton jbtnSalvar;
      private javax.swing.JLabel jlblID;
      private javax.swing.JLabel jlblNome;
      private javax.swing.JList jlstDepartamento;
      private javax.swing.JTextField jtxtID;
      private javax.swing.JTextField jtxtNome;
      // End of variables declaration

    private void Limpar() {
    jtxtID.setText("");
    jtxtNome.setText("");

    }

    private void preencherTela(Departamento dpto) {
    jtxtID.setText(dpto.getId() + “”);
    jtxtNome.setText(dpto.getNome().toUpperCase());
    }

    private void povoarJList(DepartamentoDAO daoDepto) {

     DefaultListModel modelo = new DefaultListModel();
     List<Departamento> listaDepto = daoDepto.getBanco();
     jlstDepartamento.setModel(modelo);
     for (Departamento dpto : listaDepto) {
         modelo.addElement(dpto.getId() + "-" + dpto.getNome());
     }
    

    }
    }
    [/code]

Tópico movido para o fórum de interface gráfica.

E qual é a dúvida? Faça o que seu professor pediu. :wink:

tipo, uma parte dele é na hr q cadastrar o funcionário ele grava o q foi selecionado no combobox ai na hr q pesquisar ele ele retorna exatamente o elemento q foi selecionado no combobox

mas não estou conseguindo salvar o elemento e muito menos retornar o qual foi selecionado.