Erro ao gravar dados

14 respostas
adailton_cardoso
Bom dia! 

Estou tentando gravar dados de um contato no banco de dados e esta dando esse erro abaixo e não consigo resolver. 


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


boolean tudoOk; 
tudoOk = ValidaCampos(); 


if (!tudoOk == true){ 
    try { 

          String sqlinsert ="insert into tbContato " 
               + "(Id_Empresa,Id_DeptoContato,Nome,Telefone,Fax,Celular,Nextel," 
               + "Email1,Email2,Skype_MSN,linha_Compra) values ('"+ 

               tf_CodigoEmpresa.getText()+"','"+ 
               tf_IdDeptoContato.getText()+"','"+ 
               tf_Nomecontato.getText()+"','"+ 
               tf_Telefone.getText()+"','"+ 
               tf_Fax.getText()+"','"+ 
               tf_Celular.getText()+"','"+ 
               tf_NexTel.getText()+"','"+ 
               tf_Email1.getText()+"','"+ 
               tf_Email2.getText()+"','"+ 
               tf_SkypeMsn.getText()+"','"+ 
               tfa_Informacao.getText()+ "')"; 

               con_Contato.statement.executeUpdate(sqlinsert); 

               JOptionPane.showMessageDialog(null, 
                  "Gravação realizado com sucesso!"); 
                con_Contato.executeSQL("Select * from tbContato order by "+ordenacao); 
                con_Contato.resultset.first(); 
                mostrar_dados(); 


                 } 
                 catch (SQLException erro){ 
                 erro.printStackTrace(); 
                 JOptionPane.showMessageDialog(null, 
                "Erro a tentar Gravar o registro..."+erro); 
                 } 


                btn_Confirmar.setEnabled(false); 
                btn_Editar.setEnabled(true); 
                btn_Novo.setEnabled(true); 




} 


Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException 
at br.com.cadastro.contato.FrmcadastroContato.btn_ConfirmarActionPerformed(FrmcadastroContato.java:901) 
at br.com.cadastro.contato.FrmcadastroContato.access$4400(FrmcadastroContato.java:42) 
at br.com.cadastro.contato.FrmcadastroContato$34.actionPerformed(FrmcadastroContato.java:651) 
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:201 
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) 
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) 
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) 
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289) 
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289) 
at java.awt.Component.processMouseEvent(Component.java:6505) 
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) 
at java.awt.Component.processEvent(Component.java:6270) 
at java.awt.Container.processEvent(Container.java:2229) 
at java.awt.Component.dispatchEventImpl(Component.java:4861) 
at java.awt.Container.dispatchEventImpl(Container.java:2287) 
at java.awt.Component.dispatchEvent(Component.java:4687) 
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) 
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) 
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) 
at java.awt.Container.dispatchEventImpl(Container.java:2273) 
at java.awt.Window.dispatchEventImpl(Window.java:2719) 
at java.awt.Component.dispatchEvent(Component.java:4687) 
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703) 
at java.awt.EventQueue.access$000(EventQueue.java:102) 
at java.awt.EventQueue$3.run(EventQueue.java:662) 
at java.awt.EventQueue$3.run(EventQueue.java:660) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) 
at java.awt.EventQueue$4.run(EventQueue.java:676) 
at java.awt.EventQueue$4.run(EventQueue.java:674) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
at java.awt.EventQueue.dispatchEvent(EventQueue.java:673) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244) 
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163) 
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:155) 
at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182) 
at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219) 
at java.awt.Dialog.show(Dialog.java:1072) 
at java.awt.Component.show(Component.java:1651) 
at java.awt.Component.setVisible(Component.java:1603) 
at java.awt.Window.setVisible(Window.java:1014) 
at java.awt.Dialog.setVisible(Dialog.java:1003) 
at br.com.cadastro.contato.FrmcadastroContato$45.run(FrmcadastroContato.java:158 
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251) 
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701) 
at java.awt.EventQueue.access$000(EventQueue.java:102) 
at java.awt.EventQueue$3.run(EventQueue.java:662) 
at java.awt.EventQueue$3.run(EventQueue.java:660) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
at java.awt.EventQueue.dispatchEvent(EventQueue.java:671) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244) 
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163) 
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) 
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147) 
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139) 
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97) 



Grato

14 Respostas

L

Bom dia Adailton;

Primeiramente te aconselho a colocar seu código dentro da tag [codigo] seu código aqui [/codigo] (substitua codigo por code)para que os usuários do fórum possam ter uma melhor visualização.

Em relação ao erro gerado e com o código que postou, fica complicado de achar o erro, dê uma verificada na sua classe FrmcadastroContato.java e verifique a linha 901, veja tbm os códigos relacionados a ela (métodos em outras classes) pois o erro informa que um determinado atributo esteja null e não deveria.

Outra dica seria você fazer um debug neste trecho de código.

Qualquer coisa posta seu código mais detalhadamente.

Abraços

jks1903

Quase certo que o erro é nessa linha:

con_Contato.statement.executeUpdate(sqlinsert);

Provavelmente con_Contato não esteja instanciado, ou seja, não possui uma conexão de banco.
Poste a parte onde voce cria esse objeto.

Uma outra dica seria usar PreparedStatement ao invés de Statement, para evitar SQL Injection.

adailton_cardoso
Jks blz?

Então o erro acontece ai mesmo.

A variável é essa abaixo:

   BdConexaoDAO con_Contato,con_Depto;


o Objetto é esse:

  con_Contato = new BdConexaoDAO();
  con_Contato.abreConexao();
jks1903
adailton_cardoso:
Jks blz?

Então o erro acontece ai mesmo.

A variável é essa abaixo:

   BdConexaoDAO con_Contato,con_Depto;


o Objetto é esse:

  con_Contato = new BdConexaoDAO();
  con_Contato.abreConexao();

certo.

E o que o método abreConexao() faz?

Possivelmente não está estabelecendo a coenxão com o banco, visto que retorna NullPointerException.

adailton_cardoso

Então mais o estranho que todos os formulários grava e altera normal mais esse do contato nem por reza até combox desse formulario que carrega o departamento funciona mais para gravar está dando esse erro.

jks1903

adailton_cardoso:
Então mais o estranho que todos os formulários grava e altera normal mais esse do contato nem por reza até combox desse formulario que carrega o departamento funciona mais para gravar está dando esse erro.

VocÊ deve estar fazendo algo diferente nesse formulario.

No código que você postou (primeiro post) vocÊ não instancia con_Contato, apenas tenta um update. O problema deve estar aí.

marcospaulo.suporte

Sim, o erro ocorre pq nao está instanciado.

De qualquer forma, é sempre bom executar o .println() pra ver as saidas do codigo

System.out.println(sqlinsert);

Tente depois pegar a saida desse código e inserir diretamente no banco;

adailton_cardoso

Marcos, Boa noite!

Está estanciado o con_Contato mais infelizmente não faz a conexão com o branco de dados e não sei mais o que fazer você tem mais alguma ideia?

marcospaulo.suporte

Amigo,
Tentou pegar a saida desse codigo?

System.out.println(sqlinsert);

te mandei um mp

L

Adailton, posta sua classe de Conexão e o evento de gravar no banco atualizado.

Obs: Você informou que em outros formulários que você tem funciona, posta estes formulários também !!!

adailton_cardoso
package br.com.bd.conexao;

/**
 *
 * @author Adailton
 */

import br.com.cadastro.contato.ContatoEmpresa;
import br.com.cadastro.representante.RepresentanteEmpresa;
import br.com.cadastro.empresa.Empresa;
import java.sql.*;
import javax.swing.*;
import sun.org.mozilla.javascript.internal.ast.CatchClause;




public class BdConexaoDAO{
	
	private Connection cn;
	public PreparedStatement st;	
        public Statement statement;       
        public ResultSet resultset;
        
	
	public void abreConexao(){
                        
           String conexao="jdbc:odbc:Driver={Microsoft Access Driver "
                        + "(*.mdb)};dbq=C:/SisCom/BaseDados/BDSISCOM/SISCOM.mdb";
        
		try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
          cn = DriverManager.getConnection(conexao); 
		}  

        
		catch (ClassNotFoundException ex) {
			JOptionPane.showMessageDialog(null,
                                "Erro ao tentar conectar o banco de dados", 
                                "Erro", JOptionPane.ERROR_MESSAGE);
			System.exit(0);
        
		}
		
		catch(SQLException ex){
			
			JOptionPane.showMessageDialog(null, 
                                "Problemas com a conexão", "Erro",
                                JOptionPane.ERROR_MESSAGE);
		
		}	
	}
		
	public void fechaConexao(){
			
		try {
			cn.close();
			st.close();
		}
		catch (SQLException e) {
			
			JOptionPane.showMessageDialog(null, 
                                "Erro ao tentar fechar o banco de dados");
		}    
        }
        
        
         public void executeSQL(String sql)
       {
            try 
            {
                statement = cn.createStatement(
                        ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
                resultset = statement.executeQuery(sql);
            }
            catch(SQLException sqlex) 
            {
               JOptionPane.showMessageDialog(null,"Não foi possível "+
                       "executar o comando sql,"+sqlex+", o sql passado foi "+sql);
            }

       }
        

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

        
        boolean tudoOk;
        tudoOk = ValidaCampos();            
   
              
        if (!tudoOk == true){
        try        {                
          
            String sqlinsert ="insert into tbContato "
                    + "(Id_Empresa,Id_DeptoContato,Nome,Telefone,Fax,Celular,Nextel,"
                    + "Email1,Email2,Skype_MSN,linha_Compra) values ('"+                    
                    
                    tf_CodigoEmpresa.getText()+"','"+                
                    tf_IdDeptoContato.getText()+"','"+                   
                    tf_Nomecontato.getText()+"','"+
                    tf_Telefone.getText()+"','"+
                    tf_Fax.getText()+"','"+ 
                    tf_Celular.getText()+"','"+                    
                    tf_NexTel.getText()+"','"+  
                    tf_Email1.getText()+"','"+ 
                    tf_Email2.getText()+"','"+  
                    tf_SkypeMsn.getText()+"','"+                    
                    tfa_Informacao.getText()+ "')";         
                    
                    
                    con_Contato.statement.executeUpdate(sqlinsert); 
                    
                    JOptionPane.showMessageDialog(null,
                            "Gravação realizado com sucesso!");
                    con_Contato.executeSQL("Select * from tbContato order by "+ordenacao);
                    con_Contato.resultset.first();
                    //mostrar_dados();//irá chamar a função em que irá mostrar os dados no form
        
     
        }
        catch (SQLException erro){
             erro.printStackTrace();
            JOptionPane.showMessageDialog(null,
                    "Erro a tentar Gravar o registro..."+erro);
        } 
        
    
        btn_Confirmar.setEnabled(false);
        btn_Editar.setEnabled(true);
        btn_Novo.setEnabled(true);  
        
        
      
        }
        
      

     
    }
L

Caramba velho, seu código está tudo em uma classe assim mesmo ?

Cade os formulários que você informou que estava funcionando ?

adailton_cardoso
lucas_duzo:
Caramba velho, seu código está tudo em uma classe assim mesmo ?

Cade os formulários que você informou que estava funcionando ?

opa o evento gravar é do formulário contato e está em outra classe.

o que está funcionando segue abaixo:

          package br.com.cadastro.departamento;

import br.com.bd.conexao.BdConexaoDAO;
import java.awt.AWTKeyStroke;
import java.awt.Color;
import java.awt.KeyboardFocusManager;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Adailton Cardoso
 */
public class FrmDepartamento extends javax.swing.JDialog {

    int navega = 0; //variavel apenas para sabermos em qual botao foi clicado
    
    BdConexaoDAO con_Depto;
    String ordenacao = "Id_Depto";
    
    /** Creates new form FrmDepartamento */
    public FrmDepartamento(java.awt.Frame parent, boolean modal) {       
        
        
        super(parent, modal);
        initComponents();

        
        HashSet conj = new HashSet(this.getFocusTraversalKeys
                (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
        conj.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_ENTER, 0));
        this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, conj);

        setTitle ("Cadastro de Departamentos");
        setSize(490,395);
        setResizable(false);
        setLocationRelativeTo(null);
        
        con_Depto = new BdConexaoDAO();
        con_Depto.abreConexao();

        IconeSisCom = new javax.swing.ImageIcon(getClass().getResource
                ("/Icones/administrator1_16x16.gif"));
        setIconImage(IconeSisCom.getImage());

        btn_Confirmar.setEnabled(false);

        btn_Cancelar.setToolTipText("Cancelar Cadastro");
        btn_Confirmar.setToolTipText("Confirmar Cadastro");
        btn_Editar.setToolTipText("Editar Cadastro");
        btn_Novo.setToolTipText("Novo Cadastro");
        btn_Sair.setToolTipText("Sair do Cadastro");
        
         //Botão Sair
        btn_Sair.setToolTipText("Sair");

        // Botão Primerio
        btn_Primeiro.setToolTipText("Vai para o primeiro");

        // Botão Ultimo
        btn_Ultimo.setToolTipText("Vai para o último");

        // Botão anterior
        btn_Voltar.setToolTipText("Vai para o anterior");

        // Botão avançar
        btn_Avancar.setToolTipText("Avança para o posterior");

        // Botão Email

        tf_Nome.setToolTipText("Digite o Departamento");           
        

        //Desabilita_Campo();
        Ajusta_JTableDepartamento();
        mostrar_dados();
        

    }

   
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        buttonGroup_Ordenacao = new javax.swing.ButtonGroup();
        pln_Depto = new javax.swing.JPanel();
        lbl_Depto = new javax.swing.JLabel();
        tf_Nome = new javax.swing.JTextField();
        lbl_Codigo = new javax.swing.JLabel();
        tf_Codigo = new javax.swing.JTextField();
        pln_Botoes = new javax.swing.JPanel();
        btn_Novo = new javax.swing.JButton();
        btn_Confirmar = new javax.swing.JButton();
        btn_Editar = new javax.swing.JButton();
        btn_Cancelar = new javax.swing.JButton();
        btn_Sair = new javax.swing.JButton();
        jScrollPane_Departamento = new javax.swing.JScrollPane();
        jTable_Departamento = new javax.swing.JTable();
        pln_Ordenacao = new javax.swing.JPanel();
        jRadioButtonCodigo = new javax.swing.JRadioButton();
        jRadioButtonNome = new javax.swing.JRadioButton();
        btn_Primeiro = new javax.swing.JButton();
        btn_Avancar = new javax.swing.JButton();
        btn_Voltar = new javax.swing.JButton();
        btn_Ultimo = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(null);

        pln_Depto.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Cadastro do Departamento", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10), new java.awt.Color(0, 153, 255))); // NOI18N
        pln_Depto.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        pln_Depto.setLayout(null);

        lbl_Depto.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        lbl_Depto.setForeground(new java.awt.Color(0, 153, 255));
        lbl_Depto.setText("Depto:");
        pln_Depto.add(lbl_Depto);
        lbl_Depto.setBounds(10, 47, 31, 13);

        tf_Nome.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        tf_Nome.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        tf_Nome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_NomeActionPerformed(evt);
            }
        });
        tf_Nome.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                tf_NomeFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                tf_NomeFocusLost(evt);
            }
        });
        tf_Nome.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tf_NomeKeyReleased(evt);
            }
        });
        pln_Depto.add(tf_Nome);
        tf_Nome.setBounds(80, 42, 270, 20);

        lbl_Codigo.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        lbl_Codigo.setForeground(new java.awt.Color(0, 153, 255));
        lbl_Codigo.setText("Código:");
        pln_Depto.add(lbl_Codigo);
        lbl_Codigo.setBounds(10, 25, 40, 13);

        tf_Codigo.setEditable(false);
        tf_Codigo.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        tf_Codigo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        tf_Codigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_CodigoActionPerformed(evt);
            }
        });
        pln_Depto.add(tf_Codigo);
        tf_Codigo.setBounds(80, 20, 70, 20);

        getContentPane().add(pln_Depto);
        pln_Depto.setBounds(9, 95, 370, 80);

        pln_Botoes.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btn_Novo.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        btn_Novo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/table_(add)_16x16.gif"))); // NOI18N
        btn_Novo.setText("Novo");
        btn_Novo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_Novo.setMargin(new java.awt.Insets(12, 14, 2, 14));
        btn_Novo.setPreferredSize(new java.awt.Dimension(57, 53));
        btn_Novo.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btn_Novo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_Novo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btn_NovoMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btn_NovoMouseExited(evt);
            }
        });
        btn_Novo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_NovoActionPerformed(evt);
            }
        });

        btn_Confirmar.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        btn_Confirmar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/table_auto_format_16x16.gif"))); // NOI18N
        btn_Confirmar.setText("Confirmar");
        btn_Confirmar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_Confirmar.setMargin(new java.awt.Insets(12, 14, 2, 14));
        btn_Confirmar.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btn_Confirmar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_Confirmar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btn_ConfirmarMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btn_ConfirmarMouseExited(evt);
            }
        });
        btn_Confirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_ConfirmarActionPerformed(evt);
            }
        });

        btn_Editar.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        btn_Editar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/table_(edit)_16x16.gif"))); // NOI18N
        btn_Editar.setText("Editar");
        btn_Editar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_Editar.setMargin(new java.awt.Insets(12, 14, 2, 14));
        btn_Editar.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btn_Editar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_Editar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btn_EditarMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btn_EditarMouseExited(evt);
            }
        });
        btn_Editar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_EditarActionPerformed(evt);
            }
        });

        btn_Cancelar.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        btn_Cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/table_(delete)_16x16.gif"))); // NOI18N
        btn_Cancelar.setText("Cancelar");
        btn_Cancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_Cancelar.setMargin(new java.awt.Insets(12, 14, 2, 14));
        btn_Cancelar.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btn_Cancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_Cancelar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btn_CancelarMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btn_CancelarMouseExited(evt);
            }
        });
        btn_Cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_CancelarActionPerformed(evt);
            }
        });

        btn_Sair.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        btn_Sair.setForeground(new java.awt.Color(255, 0, 51));
        btn_Sair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/disconnect1_16x16.gif"))); // NOI18N
        btn_Sair.setText("Sair");
        btn_Sair.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_Sair.setMargin(new java.awt.Insets(12, 14, 2, 14));
        btn_Sair.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btn_Sair.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btn_Sair.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btn_SairMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btn_SairMouseExited(evt);
            }
        });
        btn_Sair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_SairActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pln_BotoesLayout = new javax.swing.GroupLayout(pln_Botoes);
        pln_Botoes.setLayout(pln_BotoesLayout);
        pln_BotoesLayout.setHorizontalGroup(
            pln_BotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pln_BotoesLayout.createSequentialGroup()
                .addComponent(btn_Novo, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_Confirmar, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_Editar, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_Cancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_Sair, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pln_BotoesLayout.setVerticalGroup(
            pln_BotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pln_BotoesLayout.createSequentialGroup()
                .addGroup(pln_BotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btn_Novo, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_Confirmar, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_Editar, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_Cancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_Sair, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        getContentPane().add(pln_Botoes);
        pln_Botoes.setBounds(10, 10, 465, 60);

        jScrollPane_Departamento.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Departamento Cadastrados", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10), new java.awt.Color(0, 153, 255))); // NOI18N
        jScrollPane_Departamento.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jScrollPane_DepartamentoMouseClicked(evt);
            }
        });

        jTable_Departamento.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        jTable_Departamento.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null}
            },
            new String [] {
                "Código", "Nome"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable_Departamento.setSelectionBackground(new java.awt.Color(102, 255, 255));
        jTable_Departamento.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable_DepartamentoMouseClicked(evt);
            }
        });
        jTable_Departamento.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTable_DepartamentoFocusGained(evt);
            }
        });
        jScrollPane_Departamento.setViewportView(jTable_Departamento);

        getContentPane().add(jScrollPane_Departamento);
        jScrollPane_Departamento.setBounds(10, 180, 465, 170);

        pln_Ordenacao.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Ordenação", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10), new java.awt.Color(0, 153, 255))); // NOI18N

        buttonGroup_Ordenacao.add(jRadioButtonCodigo);
        jRadioButtonCodigo.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        jRadioButtonCodigo.setForeground(new java.awt.Color(0, 153, 255));
        jRadioButtonCodigo.setSelected(true);
        jRadioButtonCodigo.setText("Código");
        jRadioButtonCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonCodigoActionPerformed(evt);
            }
        });

        buttonGroup_Ordenacao.add(jRadioButtonNome);
        jRadioButtonNome.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        jRadioButtonNome.setForeground(new java.awt.Color(0, 153, 255));
        jRadioButtonNome.setText("Nome");
        jRadioButtonNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonNomeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pln_OrdenacaoLayout = new javax.swing.GroupLayout(pln_Ordenacao);
        pln_Ordenacao.setLayout(pln_OrdenacaoLayout);
        pln_OrdenacaoLayout.setHorizontalGroup(
            pln_OrdenacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jRadioButtonCodigo)
            .addComponent(jRadioButtonNome)
        );
        pln_OrdenacaoLayout.setVerticalGroup(
            pln_OrdenacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pln_OrdenacaoLayout.createSequentialGroup()
                .addComponent(jRadioButtonCodigo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButtonNome)
                .addGap(0, 15, Short.MAX_VALUE))
        );

        getContentPane().add(pln_Ordenacao);
        pln_Ordenacao.setBounds(380, 95, 96, 80);

        btn_Primeiro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/skip_backward_16x16.gif"))); // NOI18N
        btn_Primeiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_PrimeiroActionPerformed(evt);
            }
        });
        getContentPane().add(btn_Primeiro);
        btn_Primeiro.setBounds(10, 75, 40, 20);

        btn_Avancar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/fast_forward_16x16.gif"))); // NOI18N
        btn_Avancar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_AvancarActionPerformed(evt);
            }
        });
        getContentPane().add(btn_Avancar);
        btn_Avancar.setBounds(90, 75, 40, 20);

        btn_Voltar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/reverse_16x16.gif"))); // NOI18N
        btn_Voltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_VoltarActionPerformed(evt);
            }
        });
        getContentPane().add(btn_Voltar);
        btn_Voltar.setBounds(50, 75, 40, 20);

        btn_Ultimo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/skip_forward_16x16.gif"))); // NOI18N
        btn_Ultimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_UltimoActionPerformed(evt);
            }
        });
        getContentPane().add(btn_Ultimo);
        btn_Ultimo.setBounds(130, 75, 40, 20);

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

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

        Abilita_Campo();
        tf_Codigo.setText("");
        tf_Nome.setText("");
        tf_Nome.requestFocus();
        btn_Confirmar.setEnabled(true);
        btn_Editar.setEnabled(false);
        btn_Novo.setEnabled(false);
       




}                                        

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

        dispose();
}                                        

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

        if (tf_Nome.getText().equals("")){
            MudaCor();
            tf_Nome.setBackground(Color.PINK);
            JOptionPane.showMessageDialog(null,"Digite o Nome Departamento",
                    "Atenção!", JOptionPane.WARNING_MESSAGE );
            tf_Nome.requestFocus();       

         return ;
        }
        
        try{
            
            String sqlinsert = " insert into tbDepartamento (Depto)values ('"+
                    tf_Nome.getText()+"')";
            
                    con_Depto.statement.executeUpdate(sqlinsert);
                    JOptionPane.showMessageDialog(null,
                            "Gravação realizado com sucesso!"); 
                    con_Depto.executeSQL("Select * from tbDepartamento  order by "+ordenacao);
                    con_Depto.resultset.next();
                    mostrar_dados();
                                
        }
            
            catch (SQLException erro){                
                JOptionPane.showMessageDialog
                        (null,"Erro a tentar Gravar o registro..."+erro);
            
            }        
        
         btn_Confirmar.setEnabled(false);
         btn_Editar.setEnabled(true);
         btn_Novo.setEnabled(true);
         
         
    }                                             

    private void btn_NovoMouseEntered(java.awt.event.MouseEvent evt) {                                      

      MouseEntered(evt);
    }                                     

    private void btn_NovoMouseExited(java.awt.event.MouseEvent evt) {                                     

        MouseExited(evt);
    }                                    

    private void btn_ConfirmarMouseEntered(java.awt.event.MouseEvent evt) {                                           

        MouseEntered(evt);
    }                                          

    private void btn_ConfirmarMouseExited(java.awt.event.MouseEvent evt) {                                          

        MouseExited(evt);
    }                                         

    private void btn_EditarMouseEntered(java.awt.event.MouseEvent evt) {                                        

        MouseEntered(evt);
    }                                       

    private void btn_EditarMouseExited(java.awt.event.MouseEvent evt) {                                       

        MouseExited(evt);
    }                                      

    private void btn_CancelarMouseEntered(java.awt.event.MouseEvent evt) {                                          

        MouseEntered(evt);
    }                                         

    private void btn_CancelarMouseExited(java.awt.event.MouseEvent evt) {                                         

        MouseExited(evt);
    }                                        

    private void btn_SairMouseEntered(java.awt.event.MouseEvent evt) {                                      

        MouseEntered(evt);
    }                                     

    private void btn_SairMouseExited(java.awt.event.MouseEvent evt) {                                     

        MouseExited(evt);
    }                                    

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

        
         try {
             String sqlupdate ="UPDATE tbDepartamento SET Depto =" 
                     + "'"+tf_Nome.getText()+  
                     "' where Id_Depto = "+tf_Codigo.getText();  
             con_Depto.statement.executeUpdate(sqlupdate);     
             
             JOptionPane.showMessageDialog(null,"Alteração realizado com sucesso!");
             
             con_Depto.executeSQL("Select * from tbDepartamento  order by "+ordenacao);
             con_Depto.resultset.next();
             mostrar_dados();
         }
         catch (SQLException erro)
         {
             JOptionPane.showMessageDialog(null,"Erro a tentar Alterar o registro..."+erro);
         } 
         
         
        btn_Editar.setEnabled(true);
        btn_Novo.setEnabled(true);
        ordem_visualizacao(ordenacao); 
        
        
    }                                          

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

        con_Depto.executeSQL("Select * from tbDepartamento  order by "+ordenacao);
        try {
        con_Depto.resultset.first(); //posiciona no primeiro registro
        } catch (SQLException ex) {
            Logger.getLogger(FrmDepartamento.class.getName()).log(Level.SEVERE, null, ex);
        }
        mostrar_dados();
        
        btn_Confirmar.setEnabled(false);
        btn_Editar.setEnabled(true);
        btn_Novo.setEnabled(true);
       
        
        
    }                                            

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

    private void tf_NomeFocusGained(java.awt.event.FocusEvent evt) {                                    

        FocusGained(evt);
        tf_Nome.setBorder(javax.swing.BorderFactory.createLineBorder(Color.RED));
    }                                   

    private void tf_NomeFocusLost(java.awt.event.FocusEvent evt) {                                  

        FocusLost(evt);
        tf_Nome.setBorder(javax.swing.BorderFactory.createLineBorder(Color.BLACK));
    }                                 

    private void tf_NomeKeyReleased(java.awt.event.KeyEvent evt) {                                    

        if (evt.getKeyCode()!=32 & evt.getKeyCode()!=8 &
            evt.getKeyCode()!=37 & evt.getKeyCode()!=39)
            tf_Nome.setText(tf_Nome.getText().toUpperCase());
    }                                   

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

        ordem_visualizacao("Id_Depto");
    }                                                  

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

        ordem_visualizacao("Depto");
    }                                                

    private void btn_PrimeiroActionPerformed(java.awt.event.ActionEvent evt) {                                             
       
        try
        {
            con_Depto.resultset.first();
            mostrar_dados();
        }
        catch(SQLException erro)
        {
            JOptionPane.showMessageDialog(null,
                    "Não foi possível ir para o primeiro registro "+erro);
        }
        
    }                                            

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

        try
        {
            con_Depto.resultset.next();
            mostrar_dados();
            navega = 2;
        }
        catch(SQLException erro)
        {
            JOptionPane.showMessageDialog(null,
                    "Não foi possível ir para o próximo registro "+erro);
        }
    }                                           

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

         try
         {
            con_Depto.resultset.previous();
            mostrar_dados();
            navega=1;
         }
         catch(SQLException erro)
         {
             JOptionPane.showMessageDialog(null,
                     "Não pode ir para o registro anterior "+erro);
         }
        
    }                                          

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

        try
        {
            con_Depto.resultset.last();
            mostrar_dados();
        }
        catch(SQLException erro)
        {
            JOptionPane.showMessageDialog(null,
                    "Não foi possivel ir para o ultimo registro "+erro);
        }            
    }                                          

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

    private void jScrollPane_DepartamentoMouseClicked(java.awt.event.MouseEvent evt) {                                                      

        
    }                                                     

    private void jTable_DepartamentoMouseClicked(java.awt.event.MouseEvent evt) {                                                 

      jT_DepartamentoMouseClicked(evt);
    }                                                

    private void jTable_DepartamentoFocusGained(java.awt.event.FocusEvent evt) {                                                
      
    }                                               


    private void jT_DepartamentoMouseClicked(MouseEvent evt) {

        Integer linha = jTable_Departamento.getSelectedRow();
        String Id_Depto = (String)jTable_Departamento.getValueAt(linha, 0);
        String Depto = (String)jTable_Departamento.getValueAt(linha, 1);
        
        tf_Codigo.setText(Id_Depto);
        tf_Nome.setText(Depto);
}
    
    
    public void Ajusta_JTableDepartamento()

    {
        jTable_Departamento.getColumnModel().getColumn(0).setPreferredWidth(20);
        jTable_Departamento.getColumnModel().getColumn(1).setPreferredWidth(350);   
        
        con_Depto.executeSQL("select * from tbDepartamento order by " +ordenacao);
             
        
        
        DefaultTableModel modelo = (DefaultTableModel)jTable_Departamento.getModel();
        modelo.setNumRows(0);        
        
        try
        {
            
            while (con_Depto.resultset.next())
                modelo.addRow(new Object [] {
                         con_Depto.resultset.getString("Id_Depto"),
                         con_Depto.resultset.getString("Depto")});
                         con_Depto.resultset.first();
        }
        catch (SQLException erro){
            JOptionPane.showMessageDialog(null,"Erro ao listar no JTable "+erro);
        }      
    }
     
    public void ordem_visualizacao(String Ordem)
    {
        ordenacao = Ordem;
        con_Depto.executeSQL("select * from tbDepartamento order by " +ordenacao);
        Ajusta_JTableDepartamento();  
        try
        {
            con_Depto.resultset.first();
        }
        catch (SQLException erro){
            JOptionPane.showMessageDialog(null,"Erro na ordenação dos dados "+erro);
        }
    }
        
        
        public void mostrar_dados()
        {
            try
            {
                tf_Codigo.setText(con_Depto.resultset.getString("Id_Depto"));
                tf_Nome.setText(con_Depto.resultset.getString("Depto"));
            }
            catch(SQLException erro)
            {
                if (navega == 1)
                    JOptionPane.showMessageDialog(null,
                            "Olha, você já está no primeiro registro");  
                
                else if (navega == 2)
                    JOptionPane.showMessageDialog(null,
                            "Olha, você já está no último registro");
                else
                    JOptionPane.showMessageDialog(null,
                            "Não localizou dados "+erro);
                navega=0;
                
            }
           
        }
        
   public void Abilita_Campo(){
        
        tf_Nome.setEnabled(true);
    }

    public void MudaCor(){
        tf_Nome.setBackground(Color.WHITE);
    }

     public void MouseEntered(MouseEvent event){

        if (event.getSource() == btn_Cancelar){
            btn_Cancelar.setBackground( new Color(153,255,255));
        }

        else if (event.getSource() == btn_Confirmar){
            btn_Confirmar.setBackground( new Color(155,255,255));
        }

        else if (event.getSource() == btn_Editar){
            btn_Editar.setBackground( new Color(155,255,255));
        }

        else if (event.getSource() == btn_Novo){
            btn_Novo.setBackground( new Color(155,255,255));
        }

        else if (event.getSource() == btn_Sair){
            btn_Sair.setBackground( new Color(155,255,255));
        }
    }

    public void MouseExited(MouseEvent event){

         if (event.getSource() == btn_Cancelar){
            btn_Cancelar.setBackground(null);
        }

        else if (event.getSource() == btn_Confirmar){
            btn_Confirmar.setBackground(null);
        }

        else if (event.getSource() == btn_Editar){
            btn_Editar.setBackground(null);
        }

        else if (event.getSource() == btn_Novo){
            btn_Novo.setBackground(null);
        }

        else if (event.getSource() == btn_Sair){
            btn_Sair.setBackground(null);
        }

    }

      public void FocusGained(FocusEvent event){

        if (event.getSource() == tf_Nome){
            tf_Nome.setBackground(new Color(245,249,214));
        }
      }

      public void FocusLost (FocusEvent event){
        if (event.getSource() == tf_Nome){
            tf_Nome.setBackground(Color.WHITE);
        }
      }


    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                FrmDepartamento dialog = new FrmDepartamento(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.JButton btn_Avancar;
    private javax.swing.JButton btn_Cancelar;
    private javax.swing.JButton btn_Confirmar;
    private javax.swing.JButton btn_Editar;
    private javax.swing.JButton btn_Novo;
    private javax.swing.JButton btn_Primeiro;
    private javax.swing.JButton btn_Sair;
    private javax.swing.JButton btn_Ultimo;
    private javax.swing.JButton btn_Voltar;
    private javax.swing.ButtonGroup buttonGroup_Ordenacao;
    private javax.swing.JRadioButton jRadioButtonCodigo;
    private javax.swing.JRadioButton jRadioButtonNome;
    private javax.swing.JScrollPane jScrollPane_Departamento;
    private javax.swing.JTable jTable_Departamento;
    private javax.swing.JLabel lbl_Codigo;
    private javax.swing.JLabel lbl_Depto;
    private javax.swing.JPanel pln_Botoes;
    private javax.swing.JPanel pln_Depto;
    private javax.swing.JPanel pln_Ordenacao;
    private javax.swing.JTextField tf_Codigo;
    private javax.swing.JTextField tf_Nome;
    // End of variables declaration                   
    private ImageIcon IconeSisCom;

}
L

Seguinte;

Seu evento btn_SairMouseExited funciona ?

Pois ela está do mesmo jeito que seu evento btn_ConfirmarActionPerformed

O que vi aqui é que em nenhum momento você cria a Statement.

createStatement();

tente cria lá e teste !!!

Criado 2 de abril de 2013
Ultima resposta 3 de abr. de 2013
Respostas 14
Participantes 4