Oii!
Ok, segue o código todo, das duas classes!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* CadProd.java
*
* Created on 27/06/2009, 18:16:50
*/
package svpGui;
//import java.util.logging.Level;
//import java.util.logging.Logger;
import javax.swing.*;
import svpCodigo.ConectaProdt;
import svpCodigo.Conexao;
import svpCodigo.Consulta;
/**
*
* @author Meninas
*/
public class CadProd extends javax.swing.JFrame {
/** Creates new form CadProd */
public CadProd() {
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() {
jlTitulo = new javax.swing.JLabel();
jlDescricao = new javax.swing.JLabel();
tDescricao = new javax.swing.JTextField();
jlPrecoVenda = new javax.swing.JLabel();
tPrecoVenda = new javax.swing.JTextField();
jlBloqueado = new javax.swing.JLabel();
cbBloqueado = new javax.swing.JComboBox();
bSalvar = new javax.swing.JButton();
bCancelar = new javax.swing.JButton();
bSair = new javax.swing.JButton();
bAjuda = new javax.swing.JButton();
bAlterar = new javax.swing.JButton();
jlCodProd = new javax.swing.JLabel();
tCodProd = new javax.swing.JTextField();
bConsulta = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Cadastro de Produtos");
jlTitulo.setFont(new java.awt.Font("Tahoma", 1, 36));
jlTitulo.setText("Cadastro de Produtos");
jlDescricao.setFont(new java.awt.Font("Tahoma", 1, 14));
jlDescricao.setText("Descrição");
tDescricao.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
tDescricao.setName("tDescricao"); // NOI18N
jlPrecoVenda.setFont(new java.awt.Font("Tahoma", 1, 14));
jlPrecoVenda.setText("Preço de Venda - R$");
tPrecoVenda.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
tPrecoVenda.setToolTipText("Utilize o ponto para separar valores Ex: 1.00");
tPrecoVenda.setName("tPrecoVenda"); // NOI18N
jlBloqueado.setFont(new java.awt.Font("Tahoma", 1, 14));
jlBloqueado.setText("Bloqueado");
cbBloqueado.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
cbBloqueado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sim", "Não" }));
cbBloqueado.setToolTipText("Informe se o produto esta bloqueado para venda");
cbBloqueado.setName("cbBloqueado"); // NOI18N
bSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/Save.gif"))); // NOI18N
bSalvar.setText("Salvar");
bSalvar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bSalvarActionPerformed(evt);
}
});
bCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/Delete.gif"))); // NOI18N
bCancelar.setText("Cancelar");
bSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/Exit.gif"))); // NOI18N
bSair.setText("Sair");
bSair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bSairActionPerformed(evt);
}
});
bAjuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20png/Bulb.png"))); // NOI18N
bAjuda.setText("Ajuda");
bAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/DocumentDraw.gif"))); // NOI18N
bAlterar.setText("Alterar");
jlCodProd.setFont(new java.awt.Font("Tahoma", 1, 14));
jlCodProd.setText("Código");
tCodProd.setEditable(false);
tCodProd.setFont(new java.awt.Font("Tahoma", 0, 14));
bConsulta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/16x16/Binocular.gif"))); // NOI18N
bConsulta.setToolTipText("Clique para selecionar um produto ja cadastrado");
bConsulta.setName("bConsulta"); // NOI18N
bConsulta.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bConsultaActionPerformed(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(27, 27, 27)
.addComponent(bAlterar)
.addGap(50, 50, 50)
.addComponent(bSalvar)
.addGap(47, 47, 47)
.addComponent(bCancelar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
.addComponent(bAjuda)
.addGap(46, 46, 46)
.addComponent(bSair)
.addGap(30, 30, 30))
.addGroup(layout.createSequentialGroup()
.addGap(80, 80, 80)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jlDescricao))
.addComponent(jlCodProd))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 446, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jlTitulo)
.addGroup(layout.createSequentialGroup()
.addComponent(tCodProd, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bConsulta, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addComponent(jlPrecoVenda)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(tPrecoVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(51, 51, 51)
.addComponent(jlBloqueado)
.addGap(18, 18, 18)
.addComponent(cbBloqueado, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(88, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(45, 45, 45)
.addComponent(jlTitulo)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGap(67, 67, 67)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jlCodProd)
.addComponent(tCodProd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(45, 45, 45))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bConsulta)
.addGap(44, 44, 44)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jlDescricao))
.addGap(42, 42, 42)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jlPrecoVenda)
.addComponent(tPrecoVenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jlBloqueado)
.addComponent(cbBloqueado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 90, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bAlterar)
.addComponent(bSalvar)
.addComponent(bCancelar)
.addComponent(bAjuda)
.addComponent(bSair))
.addGap(38, 38, 38))
);
pack();
}// </editor-fold>
private void bSairActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//Conexao fecha = new Conexao();
//fecha.desconeta();
CadProd.this.dispose();
}
private void bSalvarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//String bloqueioP;
float valor;
valor = Float.parseFloat(tPrecoVenda.getText());
if (valor < 0){JOptionPane.showMessageDialog(null, "Digite um preço maior que zero");}
else{
if (tDescricao.getText().equals("")||tPrecoVenda.getText().equals("")){
JOptionPane.showMessageDialog(null, "Preencha todos os campos obrigatorios");
}
else {
ConectaProdt conPt = new ConectaProdt(tDescricao, tPrecoVenda, cbBloqueado);
JOptionPane.showMessageDialog(null, "Produto cadastrado com sucesso");
tDescricao.setText("");
tPrecoVenda.setText("");
tDescricao.requestFocus();
}
}
}
private void bConsultaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ConsProdt cProduto = new ConsProdt();
cProduto.setVisible(true);
tCodProd.setText(cProduto.getCodProd());
tDescricao.setText(cProduto.getDescricao());
tPrecoVenda.setText(cProduto.getPrecoVenda());
//cbBloqueado.getSelectedIndex(cProduto.getBloqueado());
}
public void Atualiza(JTextField cod, JTextField desc, JTextField preco, JComboBox bloq ){
String cod1 = cod.getText();
String desc1 = desc.getText();
String preco1 = preco.getText();
//int bloq1 = bloq.setSelectedIndex();
tCodProd.setText("cod1");
tDescricao.setText("desc1");
tPrecoVenda.setText("preco1");
//cbBloqueado.setSelectedItem(bloq);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CadProd().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton bAjuda;
private javax.swing.JButton bAlterar;
private javax.swing.JButton bCancelar;
private javax.swing.JButton bConsulta;
private javax.swing.JButton bSair;
private javax.swing.JButton bSalvar;
private javax.swing.JComboBox cbBloqueado;
private javax.swing.JLabel jlBloqueado;
private javax.swing.JLabel jlCodProd;
private javax.swing.JLabel jlDescricao;
private javax.swing.JLabel jlPrecoVenda;
private javax.swing.JLabel jlTitulo;
private javax.swing.JTextField tCodProd;
private javax.swing.JTextField tDescricao;
private javax.swing.JTextField tPrecoVenda;
// End of variables declaration
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* ConsProdt.java
*
* Created on 14/11/2009, 16:16:03
*/
package svpGui;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import svpCodigo.Conexao;
/**
*
* @author fernanda
*/
public class ConsProdt extends javax.swing.JFrame {
Conexao conCons;
/** Creates new form ConsProdt */
public ConsProdt() {
initComponents();
conCons = new Conexao();
conCons.conecta();
conCons.executeSql("SELECT * FROM produto");
try{
conCons.rs.first();
MostraProdt();
}catch(Exception e){
System.out.print(e);
}
}
/** 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() {
jlTitulo = new javax.swing.JLabel();
jlCodProd = new javax.swing.JLabel();
tCodProd = new javax.swing.JTextField();
jlDescricao = new javax.swing.JLabel();
tDescricao = new javax.swing.JTextField();
jlPrecoVenda = new javax.swing.JLabel();
tPrecoVenda = new javax.swing.JTextField();
jlBloqueado = new javax.swing.JLabel();
cbBloqueado = new javax.swing.JComboBox();
bProximo = new javax.swing.JButton();
bSair = new javax.swing.JButton();
bPrimeiro = new javax.swing.JButton();
bAnterior = new javax.swing.JButton();
bPesquisar = new javax.swing.JButton();
bUltimo = new javax.swing.JButton();
tPesquisa = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
bOK = new javax.swing.JButton();
bAjuda = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Consulta de Produtos");
jlTitulo.setFont(new java.awt.Font("Tahoma", 1, 36));
jlTitulo.setText("Consulta de Produtos");
jlCodProd.setFont(new java.awt.Font("Tahoma", 1, 14));
jlCodProd.setText("Código");
tCodProd.setFont(new java.awt.Font("Tahoma", 0, 14));
jlDescricao.setFont(new java.awt.Font("Tahoma", 1, 14));
jlDescricao.setText("Descrição");
tDescricao.setFont(new java.awt.Font("Tahoma", 0, 14));
tDescricao.setName("tDescricao"); // NOI18N
jlPrecoVenda.setFont(new java.awt.Font("Tahoma", 1, 14));
jlPrecoVenda.setText("Preço de Venda - R$");
tPrecoVenda.setFont(new java.awt.Font("Tahoma", 0, 14));
tPrecoVenda.setToolTipText("Utilize o ponto para separar valores Ex: 1.00");
tPrecoVenda.setName("tPrecoVenda"); // NOI18N
jlBloqueado.setFont(new java.awt.Font("Tahoma", 1, 14));
jlBloqueado.setText("Bloqueado");
cbBloqueado.setFont(new java.awt.Font("Tahoma", 0, 14));
cbBloqueado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sim", "Não" }));
cbBloqueado.setToolTipText("Informe se o produto esta bloqueado para venda");
cbBloqueado.setName("cbBloqueado"); // NOI18N
bProximo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/VCRForward.gif"))); // NOI18N
bProximo.setText("Próximo");
bProximo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bProximoActionPerformed(evt);
}
});
bSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/Exit.gif"))); // NOI18N
bSair.setText("Sair");
bSair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bSairActionPerformed(evt);
}
});
bPrimeiro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/VCRBegin.gif"))); // NOI18N
bPrimeiro.setText("Primeiro");
bPrimeiro.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bPrimeiroActionPerformed(evt);
}
});
bAnterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/VCRBack.gif"))); // NOI18N
bAnterior.setText("Anterior");
bAnterior.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bAnteriorActionPerformed(evt);
}
});
bPesquisar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/BlueCircle.gif"))); // NOI18N
bPesquisar.setText("Pesquisar");
bPesquisar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bPesquisarActionPerformed(evt);
}
});
bUltimo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/VCREnd.gif"))); // NOI18N
bUltimo.setText("Último");
bUltimo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bUltimoActionPerformed(evt);
}
});
tPesquisa.setFont(new java.awt.Font("Tahoma", 0, 14));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
jLabel1.setText("Pesquisar por Descrição");
bOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20/Check.gif"))); // NOI18N
bOK.setText("OK");
bOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bOKActionPerformed(evt);
}
});
bAjuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/javalobby/icons/20x20png/Bulb.png"))); // NOI18N
bAjuda.setText("Ajuda");
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(56, 56, 56)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(bPesquisar))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jlDescricao)
.addComponent(jlCodProd))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE)
.addComponent(tCodProd, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(bPrimeiro)
.addGap(14, 14, 14)
.addComponent(bAnterior)
.addGap(18, 18, 18)
.addComponent(bProximo)
.addGap(10, 10, 10)
.addComponent(bUltimo))
.addGroup(layout.createSequentialGroup()
.addComponent(jlPrecoVenda)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(tPrecoVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(51, 51, 51)
.addComponent(jlBloqueado)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cbBloqueado, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addGap(104, 104, 104)
.addComponent(jlTitulo)))
.addGap(108, 108, 108))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(195, Short.MAX_VALUE)
.addComponent(bOK)
.addGap(36, 36, 36)
.addComponent(bAjuda)
.addGap(18, 18, 18)
.addComponent(bSair)
.addGap(238, 238, 238))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jlTitulo)
.addGap(33, 33, 33)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(tPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bPesquisar))
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tCodProd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jlCodProd))
.addGap(45, 45, 45)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jlDescricao))
.addGap(42, 42, 42)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jlPrecoVenda)
.addComponent(tPrecoVenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jlBloqueado)
.addComponent(cbBloqueado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bPrimeiro)
.addComponent(bUltimo)
.addComponent(bAnterior)
.addComponent(bProximo))
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bSair)
.addComponent(bOK)
.addComponent(bAjuda))
.addContainerGap())
);
pack();
}// </editor-fold>
private void bProximoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//conCons = new Conexao();
//conCons.conecta();
//conCons.executeSql("SELECT * FROM produto");
try{
conCons.rs.next();
MostraProdt();
if (! conCons.rs.next()){JOptionPane.showMessageDialog(null, "Não há mais registros");}
}catch(Exception e){
System.out.print(e);
}
}
private void bSairActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ConsProdt.this.dispose();
}
private void bPrimeiroActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
conCons = new Conexao();
conCons.conecta();
conCons.executeSql("SELECT * FROM produto");
try{
conCons.rs.first();
MostraProdt();
}catch(Exception e){
System.out.print(e);
}
}
private void bAnteriorActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
conCons = new Conexao();
conCons.conecta();
conCons.executeSql("SELECT * FROM produto");
try{
conCons.rs.previous();
MostraProdt();
}catch(SQLException e){
System.out.print(e);
}
}
private void bPesquisarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
conCons.rs.first();
String igual = "n";
int tamPesq = tPesquisa.getText().length();
while (igual == "n"){
String pesquisado = conCons.rs.getString("descricao").substring(0, (tamPesq));
if (pesquisado.equals(tPesquisa.getText())){
igual = "s";
}else conCons.rs.next();
}
MostraProdt();
}catch(Exception e){
System.out.print(e);
}
}
private void bUltimoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
conCons = new Conexao();
conCons.conecta();
conCons.executeSql("SELECT * FROM produto");
try{
conCons.rs.last();
MostraProdt();
}catch(Exception e){
System.out.print("Não foi possivel localizar o ultimo registro" +e);
}
}
private void bOKActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//CadProd mostra = new CadProd();
//mostra.Atualiza(tCodProd, tDescricao, tPrecoVenda, cbBloqueado);
ConsProdt.this.dispose();
return;
}
public void MostraProdt(){
try{
tCodProd.setText(conCons.rs.getString("codigo"));
tPrecoVenda.setText(conCons.rs.getString("preco"));
cbBloqueado.setSelectedItem(conCons.rs.getString("bloqueado"));
tDescricao.setText(conCons.rs.getString("descricao"));
}catch(Exception e){
System.out.print(e);
}
}
public String getCodProd(){
return tCodProd.getText();
}
public String getDescricao(){
return tDescricao.getText();
}
public String getPrecoVenda(){
return tPrecoVenda.getText();
}
public String getBloqueado(){
return cbBloqueado.getSelectedItem().toString();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ConsProdt().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton bAjuda;
private javax.swing.JButton bAnterior;
private javax.swing.JButton bOK;
private javax.swing.JButton bPesquisar;
private javax.swing.JButton bPrimeiro;
private javax.swing.JButton bProximo;
private javax.swing.JButton bSair;
private javax.swing.JButton bUltimo;
private javax.swing.JComboBox cbBloqueado;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jlBloqueado;
private javax.swing.JLabel jlCodProd;
private javax.swing.JLabel jlDescricao;
private javax.swing.JLabel jlPrecoVenda;
private javax.swing.JLabel jlTitulo;
private javax.swing.JTextField tCodProd;
private javax.swing.JTextField tDescricao;
private javax.swing.JTextField tPesquisa;
private javax.swing.JTextField tPrecoVenda;
// End of variables declaration
}
Obrigada!!