Pessoal tenho uma classe que me conecta com o db.
package Utilitarios;
import javax.swing.JOptionPane;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
public class Conexao {
private final String driver = "oracle.jdbc.driver.OracleDriver";
private final String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
String usuario = "usuario";
String senha = "senha";
public Connection conexao;
public Statement statement;
public ResultSet resultset;
public boolean conectaBanco() {
boolean result = true;
try {
Class.forName(driver);
conexao = DriverManager.getConnection(url, usuario, senha);
} catch (ClassNotFoundException driver) {
result = false;
JOptionPane.showMessageDialog(null, "Erro driver");
} catch (SQLException fonte) {
JOptionPane.showMessageDialog(null, "Erro Fonte\n" + fonte);
result = false;
}
return result;
}
public void desconectaBanco() {
try {
conexao.close();
} catch (SQLException erro) {
}
}
public void executaSQL(String sql) {
try {
statement = conexao.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
resultset = statement.executeQuery(sql);
} catch (SQLException erro) {
JOptionPane.showMessageDialog(null, "Erro ao Executar o SQL\n" + erro);
}
}
}
e tenho um cadastro de marca que utilizo essa classe
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* CadastroPais.java
*
* Created on 24/03/2010, 08:52:41
*/
package Cadastros;
import javax.swing.table.DefaultTableModel;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.text.*;
import Utilitarios.*;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import javax.swing.*;
/**
*
* @author Leandro da Silva Mariano
*/
public class CadastroMarcas extends javax.swing.JFrame
{
private Data data = new Data();
private String nome = "Marc_Codigo";
public Conexao con_Marca;
private byte conta = 0,numeroComboBox = 0;
public CadastroMarcas()
{
initComponents();
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setLocationRelativeTo(null);
bt_Novo.setEnabled(false);
bt_Alterar.setEnabled(false);
bt_Gravar.setEnabled(false);
bt_Cancelar.setEnabled(false);
try
{
con_Marca = new Conexao();
con_Marca.conectaBanco();
con_Marca.executaSQL("Select * from cad_Marcas order by Marc_Codigo");
con_Marca.resultset.first();
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Encontrar Nenhuma Marcas Cadastrado Até o Momento.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
PreencheDados();
PreencheTabela("select * from cad_Marcas order by "+this.nome+"");
tf_Pesquisa.requestFocus();
}
private void PreencheDados()
{
try
{
bt_Novo.setEnabled(false);
bt_Alterar.setEnabled(false);
bt_Gravar.setEnabled(false);
bt_Cancelar.setEnabled(false);
tf_Codigo.setEditable(false);
tf_Nome.setEditable(false);
tf_Codigo.setText(con_Marca.resultset.getString("Marc_Codigo"));
tf_Nome.setText(con_Marca.resultset.getString("Marc_Nome"));
}
catch(SQLException erro)
{
if(conta == 1)
{
JOptionPane.showMessageDialog(null,"Atenção! Voçê já Está na Primeira Marca Cadastrada.","Informação do Sistema",JOptionPane.WARNING_MESSAGE);
}
else if(conta == 2)
{
JOptionPane.showMessageDialog(null,"Atenção! Voçê já Está na Última Marca Cadastrada.","Informação do Sistema",JOptionPane.WARNING_MESSAGE);
}
else
JOptionPane.showMessageDialog(null,"Não Foi Possivel Preencher os Dados das Marca Cadastradas.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
private void PreencheTabela(String sqlTable)
{
jTable1.getColumnModel().getColumn(0).setPreferredWidth(10);
jTable1.getColumnModel().getColumn(1).setPreferredWidth(540);
DefaultTableModel modelo = (DefaultTableModel)jTable1.getModel();
modelo.setNumRows(0);
try
{
con_Marca.executaSQL(sqlTable);
con_Marca.resultset.first();
modelo.addRow(new Object[]{con_Marca.resultset.getString("Marc_Codigo"),con_Marca.resultset.getString("Marc_Nome")});
while(con_Marca.resultset.next())
{
modelo.addRow(new Object[]{con_Marca.resultset.getString("Marc_Codigo"),con_Marca.resultset.getString("Marc_Nome")});
}
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Preencher as Linhas da Tabela!","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
public void Ordenacao(String nome)
{
try
{
this.nome = nome;
con_Marca.executaSQL("select * from cad_Marcas order by "+this.nome);
con_Marca.resultset.first();
PreencheDados();
PreencheTabela("select * from cad_Marcas order by "+this.nome+"");
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Ordenar as Marcas.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
/** 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() {
bg_Pais = new javax.swing.ButtonGroup();
pn_Titulo = new javax.swing.JPanel();
lb_Titulo = new javax.swing.JLabel();
bt_Primeiro = new javax.swing.JButton();
bt_Anterior = new javax.swing.JButton();
bt_Proximo = new javax.swing.JButton();
bt_Ultimo = new javax.swing.JButton();
bt_Inserir = new javax.swing.JButton();
bt_Cancelar = new javax.swing.JButton();
bt_Alterar = new javax.swing.JButton();
bt_Gravar = new javax.swing.JButton();
bt_Excluir = new javax.swing.JButton();
bt_Sair = new javax.swing.JButton();
bt_Filtrar = new javax.swing.JButton();
bt_Novo = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
lb_Codigo = new javax.swing.JLabel();
lb_Pesquisa = new javax.swing.JLabel();
lb_Nome = new javax.swing.JLabel();
tf_Nome = new javax.swing.JTextField();
pn_Botoes = new javax.swing.JPanel();
rb_Codigo = new javax.swing.JRadioButton();
rb_Nome = new javax.swing.JRadioButton();
tf_Pesquisa = new javax.swing.JTextField();
tf_Codigo = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Manutenção de Cadastro de Marcas.");
setResizable(false);
pn_Titulo.setBackground(new java.awt.Color(153, 0, 0));
lb_Titulo.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
lb_Titulo.setText("Cadastro de Marcas");
javax.swing.GroupLayout pn_TituloLayout = new javax.swing.GroupLayout(pn_Titulo);
pn_Titulo.setLayout(pn_TituloLayout);
pn_TituloLayout.setHorizontalGroup(
pn_TituloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pn_TituloLayout.createSequentialGroup()
.addGap(253, 253, 253)
.addComponent(lb_Titulo)
.addContainerGap(343, Short.MAX_VALUE))
);
pn_TituloLayout.setVerticalGroup(
pn_TituloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pn_TituloLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lb_Titulo, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
bt_Primeiro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/first2.gif"))); // NOI18N
bt_Primeiro.setMnemonic('p');
bt_Primeiro.setToolTipText("Click Para Ir Para o Primeiro Registro(Marca) Cadastrado. ");
bt_Primeiro.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_PrimeiroActionPerformed(evt);
}
});
bt_Anterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/anterior.gif"))); // NOI18N
bt_Anterior.setMnemonic('o');
bt_Anterior.setToolTipText("Click Para Ir Para o Registro(Marca) Anterior Cadastrado.");
bt_Anterior.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_AnteriorActionPerformed(evt);
}
});
bt_Proximo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/next2.gif"))); // NOI18N
bt_Proximo.setMnemonic('i');
bt_Proximo.setToolTipText("Click Para Ir Para o Proxímo Registro(Marca) Cadastrado.");
bt_Proximo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_ProximoActionPerformed(evt);
}
});
bt_Ultimo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/last2.gif"))); // NOI18N
bt_Ultimo.setMnemonic('u');
bt_Ultimo.setToolTipText("Click Para Ir Para o Último Registro(Marca) Cadastrado.");
bt_Ultimo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_UltimoActionPerformed(evt);
}
});
bt_Inserir.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
bt_Inserir.setForeground(new java.awt.Color(153, 0, 0));
bt_Inserir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/coleta de dados2.gif"))); // NOI18N
bt_Inserir.setMnemonic('i');
bt_Inserir.setText("Inserir");
bt_Inserir.setToolTipText("Click Para INSERIR ou ALTERAR os Dados Cadastrados.");
bt_Inserir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_InserirActionPerformed(evt);
}
});
bt_Cancelar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
bt_Cancelar.setForeground(new java.awt.Color(153, 0, 0));
bt_Cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/sol_cancelar.gif"))); // NOI18N
bt_Cancelar.setMnemonic('c');
bt_Cancelar.setText("Cancelar");
bt_Cancelar.setToolTipText("Click Para CANCELAR o Cadastro.");
bt_Cancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_CancelarActionPerformed(evt);
}
});
bt_Alterar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
bt_Alterar.setForeground(new java.awt.Color(153, 0, 0));
bt_Alterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/EditW2.gif"))); // NOI18N
bt_Alterar.setMnemonic('a');
bt_Alterar.setText("Alterar");
bt_Alterar.setToolTipText("Click Para ALTERAR os Dados Cadastrados.");
bt_Alterar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_AlterarActionPerformed(evt);
}
});
bt_Gravar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
bt_Gravar.setForeground(new java.awt.Color(153, 0, 0));
bt_Gravar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/SaveW2.gif"))); // NOI18N
bt_Gravar.setMnemonic('g');
bt_Gravar.setText("Gravar");
bt_Gravar.setToolTipText("Click Para GRAVAR os Dados Inseridos.");
bt_Gravar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_GravarActionPerformed(evt);
}
});
bt_Excluir.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
bt_Excluir.setForeground(new java.awt.Color(153, 0, 0));
bt_Excluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/DeleteW2.gif"))); // NOI18N
bt_Excluir.setMnemonic('e');
bt_Excluir.setText("Excluir");
bt_Excluir.setToolTipText("Click Para EXCLUIR a Marca Visualizado.");
bt_Excluir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_ExcluirActionPerformed(evt);
}
});
bt_Sair.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
bt_Sair.setForeground(new java.awt.Color(153, 0, 0));
bt_Sair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/finalizar2.gif"))); // NOI18N
bt_Sair.setMnemonic('s');
bt_Sair.setText("Sair");
bt_Sair.setToolTipText("Click Para SAIR do Formulário de Cadastro de Marcas.");
bt_Sair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_SairActionPerformed(evt);
}
});
bt_Filtrar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
bt_Filtrar.setForeground(new java.awt.Color(153, 0, 0));
bt_Filtrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/UndoW2.gif"))); // NOI18N
bt_Filtrar.setMnemonic('f');
bt_Filtrar.setText("Filtrar");
bt_Filtrar.setToolTipText("Click Para Mostrar na Tabela a Marca Selecionada.");
bt_Filtrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_FiltrarActionPerformed(evt);
}
});
bt_Novo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
bt_Novo.setForeground(new java.awt.Color(153, 0, 0));
bt_Novo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/NewW2.gif"))); // NOI18N
bt_Novo.setMnemonic('n');
bt_Novo.setText("Novo");
bt_Novo.setToolTipText("Click Para INSERIR Uma Nova Marca.");
bt_Novo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bt_NovoActionPerformed(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Cadastro de Marcas"));
lb_Codigo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
lb_Codigo.setForeground(new java.awt.Color(153, 0, 0));
lb_Codigo.setText("Código.:");
lb_Pesquisa.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
lb_Pesquisa.setForeground(new java.awt.Color(153, 0, 0));
lb_Pesquisa.setText("Pequisar.:");
lb_Nome.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
lb_Nome.setForeground(new java.awt.Color(153, 0, 0));
lb_Nome.setText("Nome.:");
tf_Nome.setToolTipText("Digite o Nome de Uma Marca Que Voçê Deseja Cadastrar.");
tf_Nome.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
tf_NomeKeyTyped(evt);
}
});
pn_Botoes.setBackground(new java.awt.Color(153, 0, 0));
rb_Codigo.setBackground(new java.awt.Color(0, 153, 153));
bg_Pais.add(rb_Codigo);
rb_Codigo.setSelected(true);
rb_Codigo.setText("Ordenar Por Código");
rb_Codigo.setToolTipText("Click AQUI Para Organizar as Marcas Cadastradas na Tabela em Ordem de Código.");
rb_Codigo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rb_CodigoActionPerformed(evt);
}
});
rb_Nome.setBackground(new java.awt.Color(0, 153, 153));
bg_Pais.add(rb_Nome);
rb_Nome.setText("Ordenar Por Nome");
rb_Nome.setToolTipText("Click AQUI Para Organizar as Marcas Cadastradas na Tabela em Ordem de Nome.");
rb_Nome.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rb_NomeActionPerformed(evt);
}
});
javax.swing.GroupLayout pn_BotoesLayout = new javax.swing.GroupLayout(pn_Botoes);
pn_Botoes.setLayout(pn_BotoesLayout);
pn_BotoesLayout.setHorizontalGroup(
pn_BotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pn_BotoesLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pn_BotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(rb_Nome, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)
.addComponent(rb_Codigo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
pn_BotoesLayout.setVerticalGroup(
pn_BotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pn_BotoesLayout.createSequentialGroup()
.addContainerGap()
.addComponent(rb_Codigo)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(rb_Nome)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
tf_Pesquisa.setToolTipText("Digite as Iniciais de Uma Marca Cadastrada e Precione ENTER Para Pesquisar.");
tf_Pesquisa.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tf_PesquisaActionPerformed(evt);
}
});
tf_Pesquisa.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
tf_PesquisaKeyTyped(evt);
}
});
tf_Codigo.setToolTipText("Código do Sistema.");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lb_Pesquisa)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tf_Pesquisa))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lb_Codigo)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tf_Codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lb_Nome)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tf_Nome, javax.swing.GroupLayout.PREFERRED_SIZE, 473, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
.addComponent(pn_Botoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lb_Pesquisa)
.addComponent(tf_Pesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lb_Codigo)
.addComponent(tf_Codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lb_Nome)
.addComponent(tf_Nome, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 5, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pn_Botoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Lista de Marcas Cadastradas"));
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null}
},
new String [] {
"Código da Marca", "Nome da Marca"
}
) {
boolean[] canEdit = new boolean [] {
false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jTable1.setToolTipText("Marcas Cadastrados.");
jScrollPane1.setViewportView(jTable1);
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, 737, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE)
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pn_Titulo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(75, 75, 75)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bt_Primeiro, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bt_Anterior, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bt_Proximo, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bt_Ultimo, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(layout.createSequentialGroup()
.addComponent(bt_Filtrar, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bt_Novo, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(bt_Alterar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bt_Inserir, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(bt_Gravar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bt_Excluir, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(bt_Cancelar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bt_Sair, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(99, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(pn_Titulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(jPanel2, 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.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bt_Primeiro, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bt_Anterior, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bt_Proximo, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bt_Ultimo, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bt_Inserir, javax.swing.GroupLayout.PREFERRED_SIZE, 21, Short.MAX_VALUE)
.addComponent(bt_Excluir, javax.swing.GroupLayout.PREFERRED_SIZE, 21, Short.MAX_VALUE)
.addComponent(bt_Sair, javax.swing.GroupLayout.PREFERRED_SIZE, 21, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bt_Cancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 21, Short.MAX_VALUE)
.addComponent(bt_Gravar, javax.swing.GroupLayout.PREFERRED_SIZE, 21, Short.MAX_VALUE)
.addComponent(bt_Alterar, javax.swing.GroupLayout.PREFERRED_SIZE, 21, Short.MAX_VALUE)
.addComponent(bt_Filtrar, javax.swing.GroupLayout.PREFERRED_SIZE, 21, Short.MAX_VALUE)
.addComponent(bt_Novo, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
pack();
}// </editor-fold>
private void rb_CodigoActionPerformed(java.awt.event.ActionEvent evt) {
Ordenacao("Marc_Codigo");
}
private void bt_ProximoActionPerformed(java.awt.event.ActionEvent evt) {
try
{
conta = 2;
con_Marca.executaSQL("Select * from cad_Marcas where Marc_Codigo > "+tf_Codigo.getText()+" order by Marc_Codigo");
con_Marca.resultset.first();
PreencheDados();
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Ir Para a Proxíma Marca Cadastrada.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
private void bt_AnteriorActionPerformed(java.awt.event.ActionEvent evt) {
try
{
conta = 1;
con_Marca.executaSQL("Select * from cad_Marcas where Marc_Codigo < "+tf_Codigo.getText()+" order by Marc_Codigo");
con_Marca.resultset.last();
PreencheDados();
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Ir Para a Marca Anterior Cadastrada.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
private void bt_PrimeiroActionPerformed(java.awt.event.ActionEvent evt) {
try
{
con_Marca.executaSQL("Select * from cad_Marcas order by Marc_Codigo");
con_Marca.resultset.first();
PreencheDados();
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Ir Para a Primeira Marca Cadastrada.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
private void bt_UltimoActionPerformed(java.awt.event.ActionEvent evt) {
try
{
con_Marca.executaSQL("Select * from cad_Marcas order by Marc_Codigo");
con_Marca.resultset.last();
PreencheDados();
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Ir Para a Última Marca Cadastrada.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
private void bt_InserirActionPerformed(java.awt.event.ActionEvent evt) {
int opcao;
Object botao[] = {"Sim","Não"};
opcao = JOptionPane.showOptionDialog(null,"Deseja Realmente Inserir ou Alterar Novos Dados?","Informação do Sistema.",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,botao,botao[0]);
if(opcao == JOptionPane.YES_OPTION)
{
bt_Novo.setEnabled(true);
bt_Alterar.setEnabled(true);
bt_Cancelar.setEnabled(true);
tf_Nome.setEditable(true);
tf_Nome.requestFocus();
}
else
return;
}
private void bt_SairActionPerformed(java.awt.event.ActionEvent evt) {
int opcao;
Object botao[] = {"Sim","Não"};
opcao = JOptionPane.showOptionDialog(null,"Deseja Realmente Sair do Sistema?","Informação do Sistema.",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,botao,botao[0]);
if(opcao == JOptionPane.YES_OPTION)
{
con_Marca.desconectaBanco();
dispose();
}
else
return;
}
private void bt_ExcluirActionPerformed(java.awt.event.ActionEvent evt) {
try
{
int opcao;
Object botao[] = {"Sim","Não"};
opcao = JOptionPane.showOptionDialog(null,"Deseja Realmente Excluir a Marca "+tf_Nome.getText()+" do Sistema?","Informação do Sistema.",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,botao,botao[0]);
if(opcao == JOptionPane.YES_OPTION)
{
String sqlDelete = "delete from cad_Marcas where Marc_Codigo = "+tf_Codigo.getText()+" ";
con_Marca.executaSQL("Select * from cad_Marcas where Marc_Codigo = "+tf_Codigo.getText()+" ");
con_Marca.resultset.first();
int delete = con_Marca.statement.executeUpdate(sqlDelete);
if(delete == 1)
{
con_Marca.executaSQL("Select * from cad_Marcas order by Marc_Codigo");
con_Marca.resultset.first();
numeroComboBox = 0;
PreencheDados();
PreencheTabela("select * from cad_Marcas order by "+this.nome+"");
JOptionPane.showMessageDialog(null,"Exclusão Realizada com Sucesso!","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Excluir a Marca Desejada.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
return;
}
}
else
return;
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Excluir os Dados Desejado.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
private void bt_GravarActionPerformed(java.awt.event.ActionEvent evt) {
try
{
int opcao;
Object botao[] = {"Sim","Não"};
opcao = JOptionPane.showOptionDialog(null,"Deseja Realmente Gravar Dados no Sistema?","Informação do Sistema.",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,botao,botao[0]);
if(opcao == JOptionPane.YES_OPTION)
{
String sqlInsert = "insert into cad_Marcas (Marc_Codigo,Marc_Nome) values " +
"("+tf_Codigo.getText()+",'"+tf_Nome.getText()+"')";
con_Marca.executaSQL(sqlInsert);
con_Marca.executaSQL("select * from cad_Marcas order by Marc_Codigo");
con_Marca.resultset.last();
numeroComboBox = 0;
PreencheDados();
PreencheTabela("select * from cad_Marcas order by "+this.nome+"");
JOptionPane.showMessageDialog(null,"Gravação Realizada com Sucesso!","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
}
else
return;
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Gravar os Dados Desejado.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
private void bt_AlterarActionPerformed(java.awt.event.ActionEvent evt) {
try
{
int opcao;
Object botao[] = {"Sim","Não"};
opcao = JOptionPane.showOptionDialog(null,"Deseja Realmente Alterar os Dados do Sistema?","Informação do Sistema.",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,botao,botao[0]);
if(opcao == JOptionPane.YES_OPTION)
{
String sqlInsert = "Update cad_Marcas set Marc_Nome = '"+tf_Nome.getText()+"' where Marc_Codigo = "+tf_Codigo.getText()+"";
con_Marca.statement.executeUpdate(sqlInsert);
con_Marca.executaSQL("select * from cad_Marcas where Marc_Codigo = "+tf_Codigo.getText()+" ");
con_Marca.resultset.first();
numeroComboBox = 0;
PreencheDados();
PreencheTabela("select * from cad_Marcas order by "+this.nome+"");
JOptionPane.showMessageDialog(null,"Alteração Realizada com Sucesso!","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
}
else
return;
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Preencher a Lista de Marcas no ComboBox","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
private void bt_NovoActionPerformed(java.awt.event.ActionEvent evt) {
try
{
int opcao;
Object botao[] = {"Sim","Não"};
opcao = JOptionPane.showOptionDialog(null,"Deseja Realmente Inserir Um Novo Registro no Sistema?","Informação do Sistema.",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,botao,botao[0]);
if(opcao == JOptionPane.YES_OPTION)
{
con_Marca.executaSQL("select * from cad_Marcas order by Marc_Codigo");
con_Marca.resultset.last();
int numero = Integer.parseInt(con_Marca.resultset.getString("Marc_Codigo"));
numero += 1;
bt_Gravar.setEnabled(true);
tf_Codigo.setText(""+numero);
tf_Nome.setText("");
tf_Nome.setEditable(true);
tf_Nome.requestFocus();
}
else
return;
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Atenção! Entre em Contato com o Administrador do Sistema Urgente.","Informação do Sistema",JOptionPane.WARNING_MESSAGE);
}
}
private void bt_CancelarActionPerformed(java.awt.event.ActionEvent evt) {
try
{
int opcao;
Object botao[] = {"Sim","Não"};
opcao = JOptionPane.showOptionDialog(null,"Deseja Realmente Cancelar o Cadastro?","Informação do Sistema.",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,botao,botao[0]);
if(opcao == JOptionPane.YES_OPTION)
{
con_Marca.executaSQL("select * from cad_Marcas order by Marc_Codigo");
con_Marca.resultset.first();
PreencheDados();
}
else
return;
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Ocorreu um Erro Durante o Cancelamento de Gravação do Cadastro.","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
}
}
private void tf_PesquisaActionPerformed(java.awt.event.ActionEvent evt) {
try
{
con_Marca.executaSQL("select * from cad_Marcas order by Marc_Codigo");
con_Marca.resultset.first();
int pesquisa = tf_Pesquisa.getText().length();
String pesquisar = "n";
while(pesquisar == "n")
{
String compara = con_Marca.resultset.getString("Marc_Nome").substring(0,pesquisa);
if(compara.equalsIgnoreCase(tf_Pesquisa.getText()))
{
pesquisar = "s";
}
else
{
con_Marca.resultset.next();
}
tf_Codigo.setText(con_Marca.resultset.getString("Marc_codigo"));
PreencheDados();
}
}
catch(SQLException erro)
{
JOptionPane.showMessageDialog(null,"Não Foi Possivel Realizar a Pesquisa com Sucesso.","Informação do Sistema",JOptionPane.ERROR_MESSAGE);
}
}
private void rb_NomeActionPerformed(java.awt.event.ActionEvent evt) {
Ordenacao("Marc_Nome");
}
private void bt_FiltrarActionPerformed(java.awt.event.ActionEvent evt) {
PreencheTabela("select * from cad_Marcas where Marc_nome like '"+tf_Pesquisa.getText()+"%'");
}
private void tf_PesquisaKeyTyped(java.awt.event.KeyEvent evt) {
char ch = evt.getKeyChar();
if (Character.isLetter(ch))
{
evt.setKeyChar(Character.toUpperCase(ch));
}
}
private void tf_NomeKeyTyped(java.awt.event.KeyEvent evt) {
char ch = evt.getKeyChar();
if (Character.isLetter(ch))
{
evt.setKeyChar(Character.toUpperCase(ch));
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run() {
new CadastroMarcas().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup bg_Pais;
private javax.swing.JButton bt_Alterar;
private javax.swing.JButton bt_Anterior;
private javax.swing.JButton bt_Cancelar;
private javax.swing.JButton bt_Excluir;
private javax.swing.JButton bt_Filtrar;
private javax.swing.JButton bt_Gravar;
private javax.swing.JButton bt_Inserir;
private javax.swing.JButton bt_Novo;
private javax.swing.JButton bt_Primeiro;
private javax.swing.JButton bt_Proximo;
private javax.swing.JButton bt_Sair;
private javax.swing.JButton bt_Ultimo;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JLabel lb_Codigo;
private javax.swing.JLabel lb_Nome;
private javax.swing.JLabel lb_Pesquisa;
private javax.swing.JLabel lb_Titulo;
private javax.swing.JPanel pn_Botoes;
private javax.swing.JPanel pn_Titulo;
private javax.swing.JRadioButton rb_Codigo;
private javax.swing.JRadioButton rb_Nome;
private javax.swing.JTextField tf_Codigo;
private javax.swing.JTextField tf_Nome;
private javax.swing.JTextField tf_Pesquisa;
// End of variables declaration
}
e tenho uma outra classe que que chama meu cadastro de marcas
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* chamaMarca.java
*
* Created on 16/07/2010, 08:53:22
*/
package Cadastros;
import javax.swing.JFrame;
/**
*
* @author leandro
*/
public class chamaMarca extends javax.swing.JFrame {
private CadastroMarcas marcasObj;
/** Creates new form chamaMarca */
public chamaMarca() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("chama MArca");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(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(140, 140, 140)
.addComponent(jButton1)
.addContainerGap(163, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(147, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(130, 130, 130))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if(marcasObj == null)
{
marcasObj = new CadastroMarcas();
marcasObj.setVisible(true);
marcasObj.setState(JFrame.NORMAL);
}
else if(marcasObj != null)
{
marcasObj.setVisible(true);
marcasObj.setState(JFrame.NORMAL);
}
else
{
marcasObj.con_Marca.conectaBanco();
marcasObj.setVisible(true);
marcasObj.setState(JFrame.NORMAL);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new chamaMarca().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration
}
o erro é de conexao fexada…me ajudem quem poder por favor