Buscar

projeto e implementação docx 1

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes
Você viu 3, do total de 25 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes
Você viu 6, do total de 25 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes
Você viu 9, do total de 25 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Prévia do material em texto

TRABALHO FINAL: 
Disciplina: Projeto e Implementação OO 
 
Aluna:CAROLINA MIRANDA DE ALMEIDA 
RODRIGUES 
MATRICULA:202003485144 
 
 
Código do sistema de cadastro e login com banco de dados: 
/* 
 * 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. 
 */ 
package carrinho_compras; 
 
import java.awt.CardLayout; 
import javax.swing.JOptionPane; 
import javax.swing.table.DefaultTableModel; 
 
/** 
 * 
 * @author carolalmeida 
 */ 
public class principal extends javax.swing.JFrame { 
 
 /** 
 * Creates new form principal 
 */ 
 public principal() { 
 initComponents(); 
 preencherTabela(); 
 jMenuBar1.setVisible(false); 
 } 
 private void preencherTabela(){ 
 DefaultTableModel model= new DefaultTableModel(null,new 
Object[]{"Id","Produto","quantidade","Preço"}); 
 model.addRow(new Object[]{"1","maçã","2","3"}); 
 model.addRow(new Object[]{"2","arroz","3","2"}); 
 model.addRow(new Object[]{"3","feijão","1","4"}); 
 model.addRow(new Object[]{"4","oleo","1","3"}); 
 jTable1.setModel(model); 
 
 } 
 
 /** 
 * 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() { 
 
 buttonGroup1 = new javax.swing.ButtonGroup(); 
 buttonGroup2 = new javax.swing.ButtonGroup(); 
 buttonGroup3 = new javax.swing.ButtonGroup(); 
 jPopupMenu1 = new javax.swing.JPopupMenu(); 
 Raiz = new javax.swing.JPanel(); 
 TelaLogin = new javax.swing.JPanel(); 
 jLabel1 = new javax.swing.JLabel(); 
 jLabel2 = new javax.swing.JLabel(); 
 CampoLogin = new javax.swing.JTextField(); 
 CampoSenha = new javax.swing.JPasswordField(); 
 jButton1 = new javax.swing.JButton(); 
 jLabel3 = new javax.swing.JLabel(); 
 jLabel4 = new javax.swing.JLabel(); 
 Cadastro = new javax.swing.JPanel(); 
 jPanel1 = new javax.swing.JPanel(); 
 jLabel5 = new javax.swing.JLabel(); 
 jLabel6 = new javax.swing.JLabel(); 
 jLabel7 = new javax.swing.JLabel(); 
 CTN = new javax.swing.JTextField(); 
 CPS = new javax.swing.JPasswordField(); 
 CPCS = new javax.swing.JPasswordField(); 
 jButton2 = new javax.swing.JButton(); 
 jPanel2 = new javax.swing.JPanel(); 
 jPanel4 = new javax.swing.JPanel(); 
 CBXC = new javax.swing.JComboBox(); 
 RBF = new javax.swing.JRadioButton(); 
 RBM = new javax.swing.JRadioButton(); 
 jPanel3 = new javax.swing.JPanel(); 
 CBS = new javax.swing.JCheckBox(); 
 CBC = new javax.swing.JCheckBox(); 
 CBE = new javax.swing.JCheckBox(); 
 tabela = new javax.swing.JPanel(); 
 jScrollPane2 = new javax.swing.JScrollPane(); 
 jTable1 = new javax.swing.JTable(); 
 ListaCompra = new javax.swing.JPanel(); 
 jScrollPane1 = new javax.swing.JScrollPane(); 
 jList1 = new javax.swing.JList(); 
 jMenuBar1 = new javax.swing.JMenuBar(); 
 jMenu1 = new javax.swing.JMenu(); 
 jMenuItem1 = new javax.swing.JMenuItem(); 
 jMenu2 = new javax.swing.JMenu(); 
 
 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 
 
 Raiz.setLayout(new java.awt.CardLayout()); 
 
 jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagem/cart.jpg"))); // 
NOI18N 
 
 jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagem/login.jpg"))); // 
NOI18N 
 
 jButton1.setText("Entrar"); 
 jButton1.addActionListener(new java.awt.event.ActionListener() { 
 public void actionPerformed(java.awt.event.ActionEvent evt) { 
 jButton1ActionPerformed(evt); 
 } 
 }); 
 
 jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagem/senha.jpg"))); 
// NOI18N 
 
 jLabel4.setText("Criar nova conta!"); 
 jLabel4.addMouseListener(new java.awt.event.MouseAdapter() { 
 public void mouseClicked(java.awt.event.MouseEvent evt) { 
 jLabel4MouseClicked(evt); 
 } 
 }); 
 
 javax.swing.GroupLayout TelaLoginLayout = new javax.swing.GroupLayout(TelaLogin); 
 TelaLogin.setLayout(TelaLoginLayout); 
 TelaLoginLayout.setHorizontalGroup( 
 TelaLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
TelaLoginLayout.createSequentialGroup() 
 .addGap(0, 0, Short.MAX_VALUE) 
 
.addGroup(TelaLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 
 .addComponent(jLabel4) 
 .addGroup(TelaLoginLayout.createSequentialGroup() 
 
.addGroup(TelaLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING) 
 .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)) 
 .addGap(28, 28, 28) 
 
.addGroup(TelaLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addComponent(CampoLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 174, 
javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addComponent(CampoSenha, javax.swing.GroupLayout.PREFERRED_SIZE, 174, 
javax.swing.GroupLayout.PREFERRED_SIZE)))) 
 .addGap(217, 217, 217)) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
TelaLoginLayout.createSequentialGroup() 
 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 
 
.addGroup(TelaLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
TelaLoginLayout.createSequentialGroup() 
 .addComponent(jLabel1) 
 .addGap(165, 165, 165)) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
TelaLoginLayout.createSequentialGroup() 
 .addComponent(jButton1) 
 .addGap(135, 135, 135)))) 
 ); 
 TelaLoginLayout.setVerticalGroup( 
 TelaLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(TelaLoginLayout.createSequentialGroup() 
 
.addGroup(TelaLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(TelaLoginLayout.createSequentialGroup() 
 .addComponent(jLabel1) 
 .addGap(26, 26, 26) 
 .addComponent(jLabel2) 
 .addGap(7, 7, 7) 
 .addComponent(jButton1)) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
TelaLoginLayout.createSequentialGroup() 
 .addComponent(CampoLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addGap(50, 50, 50))) 
 
.addGroup(TelaLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(TelaLoginLayout.createSequentialGroup().addGap(22, 22, 22) 
 .addComponent(CampoSenha, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 
 .addGroup(TelaLoginLayout.createSequentialGroup() 
 .addGap(5, 5, 5) 
 .addComponent(jLabel3))) 
 .addGap(66, 66, 66) 
 .addComponent(jLabel4) 
 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 
 ); 
 
 Raiz.add(TelaLogin, "card2"); 
 
 jPanel1.setBackground(new java.awt.Color(255, 0, 0)); 
 jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Identificação")); 
 
 jLabel5.setText("Nome:"); 
 
 jLabel6.setText("Senha"); 
 
 jLabel7.setText("Comfirmar senha:"); 
 
 jButton2.setText("Salvar"); 
 jButton2.addActionListener(new java.awt.event.ActionListener() { 
 public void actionPerformed(java.awt.event.ActionEvent evt) { 
 jButton2ActionPerformed(evt); 
 } 
 }); 
 
 javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 
 jPanel1.setLayout(jPanel1Layout); 
 jPanel1Layout.setHorizontalGroup( 
 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(jPanel1Layout.createSequentialGroup() 
 
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(jPanel1Layout.createSequentialGroup() 
 .addGap(73, 73, 73) 
 
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 
 .addComponent(jLabel6) 
 .addComponent(jLabel5)) 
 .addGap(18, 18, 18)) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
jPanel1Layout.createSequentialGroup() 
 .addContainerGap() 
 .addComponent(jLabel7) 
 .addGap(8, 8, 8))) 
 
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, 
false) 
 .addComponent(CTN) 
 .addComponent(CPS) 
 .addComponent(CPCS, javax.swing.GroupLayout.DEFAULT_SIZE, 401, 
Short.MAX_VALUE)) 
 .addContainerGap(117, Short.MAX_VALUE)) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
jPanel1Layout.createSequentialGroup() 
 .addGap(0, 0, Short.MAX_VALUE) 
 .addComponent(jButton2) 
 .addGap(58, 58, 58)) 
 ); 
 jPanel1Layout.setVerticalGroup( 
 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(jPanel1Layout.createSequentialGroup() 
 .addGap(25, 25, 25) 
 
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 
 .addComponent(jLabel5) 
 .addComponent(CTN, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 
 .addGap(18, 18, 18) 
 
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 
 .addComponent(jLabel6) 
 .addComponent(CPS, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 
 .addGap(23, 23, 23) 
 
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 
 .addComponent(jLabel7) 
 .addComponent(CPCS, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 
 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, 
Short.MAX_VALUE) 
 .addComponent(jButton2)) 
 ); 
 
 jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Genero")); 
 
 jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("cidade")); 
 
 CBXC.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "CASTANHAL", 
"BELEM", "SANTA IZABEL ", "IGARAPE AÇU" })); 
 
 javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); 
 jPanel4.setLayout(jPanel4Layout); 
 jPanel4Layout.setHorizontalGroup( 
 jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(jPanel4Layout.createSequentialGroup() 
 .addGap(77, 77, 77) 
 .addComponent(CBXC, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addContainerGap(139, Short.MAX_VALUE)) 
 ); 
 jPanel4Layout.setVerticalGroup( 
 jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
jPanel4Layout.createSequentialGroup() 
 .addContainerGap(56, Short.MAX_VALUE) 
 .addComponent(CBXC, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addGap(35, 35, 35)) 
 ); 
 
 buttonGroup1.add(RBF); 
 RBF.setText("Feminino"); 
 
 buttonGroup1.add(RBM); 
 RBM.setText("Masculino"); 
 
 javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); 
 jPanel2.setLayout(jPanel2Layout); 
 jPanel2Layout.setHorizontalGroup( 
 jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(jPanel2Layout.createSequentialGroup() 
 .addContainerGap() 
 .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 
 .addContainerGap()) 
 .addGroup(jPanel2Layout.createSequentialGroup() 
 .addGap(38, 38, 38) 
 
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 
 .addComponent(RBM) 
 .addComponent(RBF)) 
 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 
 ); 
 jPanel2Layout.setVerticalGroup( 
 jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(jPanel2Layout.createSequentialGroup() 
 .addGap(47, 47, 47) 
 .addComponent(RBF) 
 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 
 .addComponent(RBM) 
 .addGap(63, 63, 63) 
 .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 
 ); 
 
 jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("EstadoCivil")); 
 
 buttonGroup3.add(CBS); 
 CBS.setText("solteiro"); 
 
 buttonGroup3.add(CBC); 
 CBC.setText("casado"); 
 
 buttonGroup3.add(CBE); 
 CBE.setText("enrolado"); 
 
 javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); 
 jPanel3.setLayout(jPanel3Layout); 
 jPanel3Layout.setHorizontalGroup( 
 jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(jPanel3Layout.createSequentialGroup() 
 .addGap(47, 47, 47) 
 
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, 
false) 
 .addComponent(CBC, javax.swing.GroupLayout.Alignment.TRAILING, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE) 
 .addComponent(CBS, javax.swing.GroupLayout.Alignment.TRAILING, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE)) 
 .addComponent(CBE, javax.swing.GroupLayout.PREFERRED_SIZE, 100, 
javax.swing.GroupLayout.PREFERRED_SIZE)) 
 .addContainerGap(156, Short.MAX_VALUE)) 
 ); 
 jPanel3Layout.setVerticalGroup( 
 jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(jPanel3Layout.createSequentialGroup() 
 .addGap(96, 96, 96) 
 .addComponent(CBS) 
 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 
 .addComponent(CBC) 
 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
 .addComponent(CBE) 
 .addContainerGap(90, Short.MAX_VALUE)) 
 ); 
 
 javax.swing.GroupLayout CadastroLayout = new javax.swing.GroupLayout(Cadastro); 
 Cadastro.setLayout(CadastroLayout); 
 CadastroLayout.setHorizontalGroup( 
 CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
CadastroLayout.createSequentialGroup() 
 .addGap(0, 300, Short.MAX_VALUE) 
 
.addGroup(CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(CadastroLayout.createSequentialGroup() 
 .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
 .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 
 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 
 .addGap(52, 52, 52)) 
 ); 
 CadastroLayout.setVerticalGroup( 
 CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(CadastroLayout.createSequentialGroup() 
 .addGap(30, 30, 30) 
 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 
 
.addGroup(CadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 
 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 
 ); 
 
 Raiz.add(Cadastro, "cadastro"); 
 
 jTable1.setModel(new javax.swing.table.DefaultTableModel( 
 new Object [][] { 
 
 }, 
 new String [] { 
 "Title 1", "Title 2", "Title 3", "Title 4" 
 } 
 )); 
 jTable1.addMouseListener(new java.awt.event.MouseAdapter() { 
 public void mouseClicked(java.awt.event.MouseEvent evt) { 
 jTable1MouseClicked(evt); 
 } 
 }); 
 jScrollPane2.setViewportView(jTable1); 
 
 javax.swing.GroupLayout tabelaLayout = new javax.swing.GroupLayout(tabela); 
 tabela.setLayout(tabelaLayout); 
 tabelaLayout.setHorizontalGroup( 
 tabelaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
tabelaLayout.createSequentialGroup() 
 .addContainerGap(392, Short.MAX_VALUE) 
 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addGap(187, 187, 187)) 
 ); 
 tabelaLayout.setVerticalGroup( 
 tabelaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(tabelaLayout.createSequentialGroup() 
 .addGap(37, 37, 37) 
 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addContainerGap(118, Short.MAX_VALUE)) 
 ); 
 
 Raiz.add(tabela, "tabela"); 
 
 jList1.setModel(new javax.swing.AbstractListModel() { 
 String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", 
"Item 9", "Item 10", "Item 11", "Item 12", "Item 13", "Item 14", "Item 15", "Item 16", "Item 17", "Item 
18", "Item 19", "Item 20" }; 
 public int getSize() { return strings.length; } 
 public Object getElementAt(int i) { return strings[i]; } 
 }); 
 jScrollPane1.setViewportView(jList1); 
 
 javax.swing.GroupLayout ListaCompraLayout = new javax.swing.GroupLayout(ListaCompra); 
 ListaCompra.setLayout(ListaCompraLayout); 
 ListaCompraLayout.setHorizontalGroup( 
 ListaCompraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
ListaCompraLayout.createSequentialGroup() 
 .addContainerGap(587, Short.MAX_VALUE) 
 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 263, 
javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addGap(181, 181, 181)) 
 ); 
 ListaCompraLayout.setVerticalGroup( 
 ListaCompraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(ListaCompraLayout.createSequentialGroup() 
 .addGap(121, 121, 121) 
 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 289, 
javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addContainerGap(172, Short.MAX_VALUE)) 
 ); 
 
 Raiz.add(ListaCompra, "lista"); 
 
 jMenu1.setText("File"); 
 
 jMenuItem1.setText("jMenuItem1"); 
 jMenuItem1.addActionListener(new java.awt.event.ActionListener() { 
 public void actionPerformed(java.awt.event.ActionEvent evt) { 
 jMenuItem1ActionPerformed(evt); 
 } 
 }); 
 jMenu1.add(jMenuItem1); 
 
 jMenuBar1.add(jMenu1); 
 
 jMenu2.setText("Edit"); 
 jMenuBar1.add(jMenu2); 
 
 setJMenuBar(jMenuBar1); 
 
 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(425, 425, 425) 
 .addComponent(Raiz, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addGap(0, 0, Short.MAX_VALUE)) 
 ); 
 layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
 .addGroup(layout.createSequentialGroup() 
 .addComponent(Raiz, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
 .addGap(0, 0, Short.MAX_VALUE)) 
 ); 
 
 pack(); 
 }// </editor-fold> 
 
 private void jLabel4MouseClicked(java.awt.event.MouseEvent evt) { 
 CardLayout card = (CardLayout) Raiz.getLayout(); 
 
 card.show(Raiz, "cadastro"); 
 } 
 
 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { 
 String nome = "aluno"; 
 String senha = "1234"; 
 
 
 if(CampoLogin.getText().equals(nome) && 
 CampoSenha.getText().equals(senha)){ 
 
 CardLayout card = (CardLayout) Raiz.getLayout(); 
 
 card.show(Raiz, "tabela"); 
 jMenuBar1.setVisible(true); 
 } 
 } 
 
 private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { 
 
 Usuarios user = new Usuarios(); 
 String nome= ""; 
 String senha =""; 
 String genero =""; 
 String EstadoCivil=""; 
 String cidade =""; 
 if (CPS.getText().equals(CPCS.getText())){ 
 nome = CTN.getText(); 
 user.setNome(nome); 
 senha = CPS.getText(); 
 user.setSenha(senha); 
 
 
 if(RBM.isSelected()){ 
 genero ="masculino"; 
 genero = RBM.getText(); 
 user.setGenero(genero); 
 }else if(RBF.isSelected()){ 
 genero = "feminino"; 
 user.setGenero(genero); 
 } 
 
 
 if(CBS.isSelected()){ 
 EstadoCivil = "solteiro"; 
 user.setEstadoCivil(EstadoCivil); 
 } else if(CBC.isSelected()){ 
 EstadoCivil = "casado"; 
 user.setEstadoCivil(EstadoCivil); 
 }else if(CBE.isSelected()){ 
 EstadoCivil = "enrolado"; 
 user.setEstadoCivil(EstadoCivil); 
 } 
 cidade = (String) CBXC.getSelectedItem(); 
 user.setCidade(cidade); 
 System.out.println(nome+" "+senha+" "+genero+" "+EstadoCivil+" "+cidade); 
 System.out.print(user.salvar()); 
 }else{ 
 JOptionPane.showMessageDialog(null,"senhas diferentes!"); 
 } 
 
 } 
 
 private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) { 
 System.exit(0); 
 } 
 
 private void jTable1MouseClicked(java.awt.event.MouseEvent evt) { 
 if(evt.getButton()!=evt.getButton()){ 
 jPopupMenu1.show(jTable1, evt.getX(), evt.getY()); 
 
 } 
 } 
 
 /** 
 * @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(principal.class.getName()).log(java.util.logging.Level.SEVERE, 
null, ex); 
 } catch (InstantiationException ex) { 
 
java.util.logging.Logger.getLogger(principal.class.getName()).log(java.util.logging.Level.SEVERE, 
null, ex); 
 } catch (IllegalAccessException ex) { 
 
java.util.logging.Logger.getLogger(principal.class.getName()).log(java.util.logging.Level.SEVERE, 
null, ex); 
 } catch (javax.swing.UnsupportedLookAndFeelException ex) { 
 
java.util.logging.Logger.getLogger(principal.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 principal().setVisible(true); 
 } 
 }); 
 } 
 
 // Variables declaration - do not modify 
 private javax.swing.JCheckBox CBC; 
 private javax.swing.JCheckBox CBE; 
 private javax.swing.JCheckBox CBS; 
 private javax.swing.JComboBox CBXC; 
 private javax.swing.JPasswordField CPCS; 
 private javax.swing.JPasswordField CPS; 
 private javax.swing.JTextField CTN; 
 private javax.swing.JPanel Cadastro; 
 private javax.swing.JTextField CampoLogin; 
 private javax.swing.JPasswordField CampoSenha; 
 private javax.swing.JPanel ListaCompra; 
 private javax.swing.JRadioButton RBF; 
 private javax.swing.JRadioButton RBM; 
 private javax.swing.JPanel Raiz; 
 private javax.swing.JPanel TelaLogin; 
 private javax.swing.ButtonGroup buttonGroup1; 
 private javax.swing.ButtonGroup buttonGroup2; 
 private javax.swing.ButtonGroup buttonGroup3; 
 private javax.swing.JButton jButton1; 
 private javax.swing.JButton jButton2; 
 private javax.swing.JLabel jLabel1; 
 private javax.swing.JLabel jLabel2; 
 private javax.swing.JLabel jLabel3; 
 private javax.swing.JLabel jLabel4; 
 private javax.swing.JLabel jLabel5; 
 private javax.swing.JLabel jLabel6; 
 private javax.swing.JLabel jLabel7; 
 private javax.swing.JList jList1; 
 private javax.swing.JMenu jMenu1; 
 private javax.swing.JMenu jMenu2; 
 private javax.swing.JMenuBar jMenuBar1; 
 private javax.swing.JMenuItem jMenuItem1; 
 private javax.swing.JPanel jPanel1; 
 private javax.swing.JPanel jPanel2; 
 private javax.swing.JPanel jPanel3; 
 private javax.swing.JPanel jPanel4; 
 private javax.swing.JPopupMenu jPopupMenu1; 
 private javax.swing.JScrollPane jScrollPane1; 
 private javax.swing.JScrollPane jScrollPane2; 
 private javax.swing.JTable jTable1; 
 private javax.swing.JPanel tabela; 
 // End of variables declaration 
 
 
 
 } 
Usuários banco de dados dao: 
/* 
 * 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. 
 */ 
package carrinho_compras; 
 
import java.io.FileWriter; 
import java.io.PrintWriter; 
 
/** 
 * 
 * @author carolalmeida 
 */ 
public class Usuarios { 
 private String nome; 
 private String senha; 
 private String genero ; 
 private String EstadoCivil; 
 private String cidade; 
 
 public String getNome() { 
 return nome; 
 } 
 
 public void setNome(String nome) { 
 this.nome = nome; 
 } 
 
 public String getSenha() { 
 return senha; 
 } 
 
 public void setSenha(String senha) { 
 this.senha = senha; 
 } 
 
 public String getGenero() { 
 return genero; 
 } 
 
 public void setGenero(String genero) { 
 this.genero = genero; 
 } 
 
 public String getEstadoCivil(){ 
 return EstadoCivil; 
 } 
 
 public void setEstadoCivil(String EstadoCivil) { 
 this.EstadoCivil = EstadoCivil; 
 } 
 
 public String getCidade() { 
 return cidade; 
 } 
 
 public void setCidade(String cidade) { 
 this.cidade = cidade; 
 } 
 public String salvar(){ 
 
 try{ 
 FileWriter file = new FileWriter("cadastro de usarios.txt", true); 
 PrintWriter pw = new PrintWriter(file); 
 
 pw.println("nome: "+this.nome); 
 pw.println("senha: "+this.senha); 
 pw.println("genero: "+this.genero); 
 pw.println("estado civil: "+this.EstadoCivil); 
 pw.println("cidade: "+this.cidade); 
 pw.println("----------------------------------------"); 
 
 pw.flush(); 
 pw.close(); 
 
 }catch(Exception e){ 
 
 } 
 return "dados salvos com sucesso!"; 
 
 } 
}

Continue navegando