Ir ao conteúdo
  • Cadastre-se

raphael46

Membros Juniores
  • Total de itens

    3
  • Registro em

  • Última visita

  • Qualificações

    N/D
  1. package interfaceGrafica; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import javax.swing.DefaultListModel; import javax.swing.WindowConstants; import sistemadecadastro.Cliente; import sistemadecadastro.MinhaConexao; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Eduardo */ public class MeuMenu extends javax.swing.JFrame { /** * Creates new form MeuMenu */ public MeuMenu() { 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() { btnProdutos = new javax.swing.JButton(); btnVendas = new javax.swing.JButton(); btnSair = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); btnClientes = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); btnProdutos.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N btnProdutos.setText("Produtos"); btnProdutos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnProdutosActionPerformed(evt); } }); btnVendas.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N btnVendas.setText("Vendas"); btnVendas.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnVendasActionPerformed(evt); } }); btnSair.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N btnSair.setText("Sair"); jLabel1.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N jLabel1.setText("Sistema de Vendas"); btnClientes.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N btnClientes.setText("Clientes"); btnClientes.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnClientesActionPerformed(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(37, 37, 37) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 323, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btnVendas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnClientes, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btnSair, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnProdutos, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)))) .addContainerGap(40, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btnClientes, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE) .addComponent(btnProdutos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(40, 40, 40) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnVendas, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnSair, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(37, 37, 37)) ); pack(); }// </editor-fold> private void btnProdutosActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void btnClientesActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: MeusClientes mc = new MeusClientes(); mc.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); mc.setVisible(true); } private void btnVendasActionPerformed(java.awt.event.ActionEvent evt) { AdiocinarVenda v = new AdiocinarVenda(); v.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); v.setVisible(true); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MeuMenu().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton btnClientes; private javax.swing.JButton btnProdutos; private javax.swing.JButton btnSair; private javax.swing.JButton btnVendas; private javax.swing.JLabel jLabel1; // End of variables declaration ArrayList<Cliente> cliente = new ArrayList<Cliente>(); Connection conexao = MinhaConexao.getInstance().sqlConnection; //fill client list String query = "SELECT nome, cpf FROM cliente"; Statement stmt = null; try { stmt = conexao.createStatement(); ResultSet rs = stmt.executeQuery(query); while(rs.next()){ String nome = rs.getString("nome"); String cpf = rs.getString("cpf"); //adiciona cliente na lista cliente.add(new Cliente(nome, cpf)); } }catch(Exception e){ e.printStackTrace(); } DefaultListModel listModel = new DefaultListModel(); for(Cliente c : cliente){ listModel.addElement(new String(c.getNome() + " - " + c.getCPF())); System.out.println("Client name: " + c.getNome()); } listClientes.setModel(listModel); } @Override public void repaint() { super.repaint(); //To change body of generated methods, choose Tools | Templates. this.atualizaClientes(); } }
  2. package interfaceGrafica; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import javax.swing.DefaultListModel; import javax.swing.WindowConstants; import sistemadecadastro.Cliente; import sistemadecadastro.MinhaConexao; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Eduardo */ public class MeuMenu extends javax.swing.JFrame { /** * Creates new form MeuMenu */ public MeuMenu() { 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() { btnProdutos = new javax.swing.JButton(); btnVendas = new javax.swing.JButton(); btnSair = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); btnClientes = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); btnProdutos.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N btnProdutos.setText("Produtos"); btnProdutos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnProdutosActionPerformed(evt); } }); btnVendas.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N btnVendas.setText("Vendas"); btnVendas.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnVendasActionPerformed(evt); } }); btnSair.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N btnSair.setText("Sair"); jLabel1.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N jLabel1.setText("Sistema de Vendas"); btnClientes.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N btnClientes.setText("Clientes"); btnClientes.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnClientesActionPerformed(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(37, 37, 37) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 323, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btnVendas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnClientes, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btnSair, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnProdutos, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)))) .addContainerGap(40, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btnClientes, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE) .addComponent(btnProdutos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(40, 40, 40) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnVendas, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnSair, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(37, 37, 37)) ); pack(); }// </editor-fold> private void btnProdutosActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void btnClientesActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: MeusClientes mc = new MeusClientes(); mc.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); mc.setVisible(true); } private void btnVendasActionPerformed(java.awt.event.ActionEvent evt) { AdiocinarVenda v = new AdiocinarVenda(); v.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); v.setVisible(true); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MeuMenu().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton btnClientes; private javax.swing.JButton btnProdutos; private javax.swing.JButton btnSair; private javax.swing.JButton btnVendas; private javax.swing.JLabel jLabel1; // End of variables declaration ArrayList<Cliente> cliente = new ArrayList<Cliente>(); Connection conexao = MinhaConexao.getInstance().sqlConnection; //fill client list String query = "SELECT nome, cpf FROM cliente"; Statement stmt = null; try { stmt = conexao.createStatement(); ResultSet rs = stmt.executeQuery(query); while(rs.next()){ String nome = rs.getString("nome"); String cpf = rs.getString("cpf"); //adiciona cliente na lista cliente.add(new Cliente(nome, cpf)); } }catch(Exception e){ e.printStackTrace(); } DefaultListModel listModel = new DefaultListModel(); for(Cliente c : cliente){ listModel.addElement(new String(c.getNome() + " - " + c.getCPF())); System.out.println("Client name: " + c.getNome()); } listClientes.setModel(listModel); } @Override public void repaint() { super.repaint(); //To change body of generated methods, choose Tools | Templates. this.atualizaClientes(); } }
  3. E para um sistema de cadastro e vendas } public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MeuMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MeuMenu().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton btnClientes; private javax.swing.JButton btnProdutos; private javax.swing.JButton btnSair; private javax.swing.JButton btnVendas; private javax.swing.JLabel jLabel1; // End of variables declaration ArrayList<Cliente> cliente = new ArrayList<Cliente>(); Connection conexao = MinhaConexao.getInstance().sqlConnection; //fill client list String query = "SELECT nome, cpf FROM cliente"; Statement stmt = null; try { stmt = conexao.createStatement(); ResultSet rs = stmt.executeQuery(query); while(rs.next()){ String nome = rs.getString("nome"); String cpf = rs.getString("cpf"); //adiciona cliente na lista cliente.add(new Cliente(nome, cpf)); } }catch(Exception e){ e.printStackTrace(); } DefaultListModel listModel = new DefaultListModel(); for(Cliente c : cliente){ listModel.addElement(new String(c.getNome() + " - " + c.getCPF())); System.out.println("Client name: " + c.getNome()); } listClientes.setModel(listModel); } @Override public void repaint() { super.repaint(); //To change body of generated methods, choose Tools | Templates. this.atualizaClientes(); } } errros no console Exception in thread "main" java.lang.ClassFormatError: Duplicate field name&signature in class file interfaceGrafica/MeuMenu at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:367) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at sistemadecadastro.SistemaDeCadastro.main(SistemaDeCadastro.java:35) Java Result: 1 image.rar

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas publicações sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Aprenda_a_Ler_Resistores_e_Capacitores-capa-3d-newsletter.jpg

ebook grátis "Aprenda a ler resistores e capacitores", de Gabriel Torres

GRÁTIS! BAIXE AGORA MESMO!