pedro_miguel26 Posted February 7, 2017 at 03:45 PM Report Share #602385 Posted February 7, 2017 at 03:45 PM Boas pessoal, sou novo em java e estou a desenvolver uma aplicaçao de gestao de clientes e gostaria que me indicassem uma forma de fazer uma pesquisa dos clientes pelo nome na base de dados. Consigo inserir novos clientes, alterar existentes, e apagar. Ja pesquisei e nunca consegui arranjar uma forma de conseguir Obrigado desde ja e deixo aqui o codigo para quem me conseguir ajudar package cliente; import java.awt.HeadlessException; import java.sql.*; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; public class ConectaBD { public Statement stm,stml; public ResultSet rs,rsc; private final String driver="com.mysql.jdbc,driver"; private final String caminho="jdbc:mysql://localhost/bd"; private final String utilizador="root"; private final String senha=""; public Connection conn; public void conecta(){ try { System.setProperty("jdbc.drivers",driver); conn = DriverManager.getConnection(caminho,utilizador,senha); //JOptionPane.showMessageDialog(null, "Conexao bem sucedida."); } catch (HeadlessException | SQLException erro) { JOptionPane.showMessageDialog(null, "Erro de conexão: \n Erro:"+ erro.getMessage()); } } public void executaSQL(String sql){ try { stm = conn.createStatement(rs.TYPE_SCROLL_INSENSITIVE, rs.CONCUR_READ_ONLY); rs = stm.executeQuery(sql); } catch (SQLException erro) { JOptionPane.showMessageDialog(null,"Cliente não existente\n ERRO:"+ erro.getMessage()); } } public void desconecta () { try { conn.close(); JOptionPane.showMessageDialog(null,"Desconexão bem sucedida"); } catch (HeadlessException | SQLException erro) { JOptionPane.showMessageDialog(null, "Erro na Desconexão:\n Erro:"+ erro.getMessage()); } } public void executaSQLc(String sql){ try { stm = conn.createStatement(rsc.TYPE_SCROLL_INSENSITIVE, rsc.CONCUR_READ_ONLY); rsc = stm.executeQuery(sql); } catch (SQLException erro) { JOptionPane.showMessageDialog(null,"Cliente não existente\n ERRO:"+ erro.getMessage()); } } } package cliente; public class Cliente { private int cod_cliente; private String nome_cliente; private String morada_cliente; private String telefone_cliente; private String contribuinte_cliente; private String data_instalacao; private String tipo_contrato; private String data_adesao; private String per_fidelizacao; private String operador; private String localidade_cliente; private String cod_postal; private String telemovel_cliente; private String email_cliente; private String servico; public int getcod_cliente() { return cod_cliente; } public void setcod_cliente(int cod_cliente) { this.cod_cliente = cod_cliente; } public String getnome_cliente() { return nome_cliente; } public void setnome_cliente(String nome_cliente) { this.nome_cliente = nome_cliente; } public String getmorada_cliente() { return morada_cliente; } public void setmorada_cliente(String morada_cliente) { this.morada_cliente = morada_cliente; } public String gettelefone_cliente() { return telefone_cliente; } public void settelefone_cliente(String telefone_cliente) { this.telefone_cliente = telefone_cliente; } public String getcontribuinte_cliente() { return contribuinte_cliente; } public void setcontribuinte_cliente(String contribuinte_cliente) { this.contribuinte_cliente = contribuinte_cliente; } public String getdata_instalacao() { return data_instalacao; } public void setdata_instalacao(String data_instalacao) { this.data_instalacao = data_instalacao; } public String gettipo_contrato() { return tipo_contrato; } public void settipo_contrato(String tipo_contrato) { this.tipo_contrato = tipo_contrato; } public String getdata_adesao() { return data_adesao; } public void setdata_adesao(String data_adesao) { this.data_adesao = data_adesao; } public String getper_fidelizacao() { return per_fidelizacao; } public void setper_fidelizacao(String per_fidelizacao) { this.per_fidelizacao = per_fidelizacao; } public String getoperador() { return operador; } public void setoperador(String operador) { this.operador = operador; } public String getlocalidade_cliente() { return localidade_cliente; } public void setlocalidade_cliente(String localidade_cliente) { this.localidade_cliente = localidade_cliente; } public String getcod_postal() { return cod_postal; } public void setcod_postal(String cod_postal) { this.cod_postal = cod_postal; } public String gettelemovel_cliente() { return telemovel_cliente; } public void settelemovel_cliente(String telemovel_cliente) { this.telemovel_cliente = telemovel_cliente; } public String getemail_cliente() { return email_cliente; } public void setemail_cliente(String email_cliente) { this.email_cliente = email_cliente; } public String getservico() { return servico; } public void setservico(String servico) { this.servico = servico; } public Cliente(int cod_cliente, String nome_cliente, String morada_cliente, String telefone_cliente , String contribuinte_cliente, String data_instalacao,String tipo_contrato, String data_adesao, String per_fidelizacao, String operador, String localidade_cliente, String cod_postal, String telemovel_cliente, String email_cliente, String servico ) { this.cod_cliente = cod_cliente; this.nome_cliente = nome_cliente; this.morada_cliente = morada_cliente; this.telefone_cliente = telefone_cliente; this.contribuinte_cliente = contribuinte_cliente; this.data_instalacao = data_instalacao; this.tipo_contrato = tipo_contrato; this.data_adesao = data_adesao; this.per_fidelizacao = per_fidelizacao; this.operador = operador; this.localidade_cliente = localidade_cliente; this.cod_postal = cod_postal; this.telemovel_cliente = telemovel_cliente; this.email_cliente = email_cliente; this.servico = servico; } } package cliente; import cliente.ConectaBD; import java.sql.PreparedStatement; import java.sql.SQLException; import javax.swing.JOptionPane; public class Menu extends javax.swing.JFrame { ConectaBD conecta = new ConectaBD(); public Menu() { initComponents(); conecta.conecta(); carregatudo(); } public void carregatudo(){ try { conecta.executaSQL("SELECT * FROM ibit"); conecta.rs.first(); jTextCodigo.setText(String.valueOf(conecta.rs.getInt("cod_cliente"))); jTextNome.setText(conecta.rs.getString("nome_cliente")); jTextMorada.setText(conecta.rs.getString("morada_cliente")); jTextContribuinte.setText(conecta.rs.getString("contribuinte_cliente")); jTextTelefone.setText(conecta.rs.getString("telefone_cliente")); jTextdata_instalacao.setText(conecta.rs.getString("data_instalacao")); jTexttipo_contrato.setText(conecta.rs.getString("tipo_contrato")); jTextdata_adesao.setText(conecta.rs.getString("data_adesao")); jTextper_fidelizacao.setText(conecta.rs.getString("per_fidelizacao")); jTextoperadora.setText(conecta.rs.getString("operador")); jTextFieldLocalidade_cliente.setText(conecta.rs.getString("localidade_cliente")); jTextFieldCod_postal.setText(conecta.rs.getString("cod_postal")); jTextFieldTelemovel_cliente.setText(conecta.rs.getString("telemovel_cliente")); jTextFieldEmail.setText(conecta.rs.getString("email_cliente")); jTextFieldServico.setText(conecta.rs.getString("servico")); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Erro na pesquisa"); } } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jSeparator2 = new javax.swing.JSeparator(); jTextField4 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); jButton6 = new javax.swing.JButton(); jButton7 = new javax.swing.JButton(); jButton8 = new javax.swing.JButton(); jButton9 = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jTextNome = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jTextMorada = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); jTextContribuinte = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); jTextTelefone = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jTextFieldLocalidade_cliente = new javax.swing.JTextField(); jTextFieldCod_postal = new javax.swing.JTextField(); jTextFieldTelemovel_cliente = new javax.swing.JTextField(); jLabel12 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jLabel15 = new javax.swing.JLabel(); jTextFieldEmail = new javax.swing.JTextField(); jLabel6 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); jTextdata_instalacao = new javax.swing.JTextField(); jTexttipo_contrato = new javax.swing.JTextField(); jTextdata_adesao = new javax.swing.JTextField(); jTextper_fidelizacao = new javax.swing.JTextField(); jTextoperadora = new javax.swing.JTextField(); jLabel16 = new javax.swing.JLabel(); jTextFieldServico = new javax.swing.JTextField(); jPanel3 = new javax.swing.JPanel(); jTextCodigo = new javax.swing.JTextField(); jPanel5 = new javax.swing.JPanel(); jTextFieldPesquisa = new javax.swing.JTextField(); jLabel14 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jTextField4.setText("jTextField4"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton1.setText("Novo"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Alterar"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText("Eliminar"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jButton4.setText("|<"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jButton5.setText("<"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); jButton6.setText(">"); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); jButton7.setText(">|"); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt); } }); jButton8.setText("Gravar"); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); jButton9.setText("Sair"); jButton9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton9ActionPerformed(evt); } }); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Clientes", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel2.setText("Nome"); jTextNome.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextNomeActionPerformed(evt); } }); jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel3.setText("Morada"); jTextMorada.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextMoradaActionPerformed(evt); } }); jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel4.setText("Nº Contribuinte"); jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel5.setText("Telefone"); jTextTelefone.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextTelefoneActionPerformed(evt); } }); jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel1.setText("Localidade"); jTextFieldLocalidade_cliente.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextFieldLocalidade_clienteActionPerformed(evt); } }); jTextFieldCod_postal.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextFieldCod_postalActionPerformed(evt); } }); jLabel12.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel12.setText("Codigo Postal"); jLabel13.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel13.setText("Telemóvel"); jLabel15.setText("Email"); jTextFieldEmail.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextFieldEmailActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1) .addComponent(jLabel12) .addComponent(jLabel13) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel15)) .addGap(0, 131, Short.MAX_VALUE)) .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jTextNome, javax.swing.GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE) .addComponent(jTextFieldLocalidade_cliente) .addComponent(jTextFieldTelemovel_cliente) .addComponent(jTextFieldCod_postal) .addComponent(jTextTelefone) .addComponent(jTextMorada) .addComponent(jTextContribuinte, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jTextFieldEmail)) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(8, 8, 8) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jTextNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextContribuinte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel4))) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextMorada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextFieldLocalidade_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextFieldCod_postal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel12)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextFieldTelemovel_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel13)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel15) .addComponent(jTextFieldEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); jLabel6.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N jLabel6.setText("Gestão de Clientes"); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Dados", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel7.setText("Data de Instalação"); jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel8.setText("Tipo de Contrato"); jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel9.setText("Data de Adesão"); jLabel10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel10.setText("Periodo Fidelização"); jLabel11.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel11.setText("Operadora"); jLabel16.setText("Serviço"); jTextFieldServico.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextFieldServicoActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel10) .addComponent(jLabel11) .addComponent(jLabel9) .addComponent(jLabel7) .addComponent(jLabel8) .addComponent(jLabel16)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jTextper_fidelizacao, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jTextdata_adesao, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jTexttipo_contrato, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jTextdata_instalacao, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jTextoperadora) .addComponent(jTextFieldServico, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextFieldServico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel16)) .addGap(11, 11, 11) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTexttipo_contrato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel7) .addComponent(jTextdata_instalacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9) .addComponent(jTextdata_adesao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel10) .addComponent(jTextper_fidelizacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel11) .addComponent(jTextoperadora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Código Cliente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N jTextCodigo.setEditable(false); jTextCodigo.setBackground(new java.awt.Color(0, 0, 0)); jTextCodigo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N jTextCodigo.setForeground(new java.awt.Color(255, 255, 255)); jTextCodigo.setHorizontalAlignment(javax.swing.JTextField.CENTER); jTextCodigo.setCaretColor(new java.awt.Color(255, 255, 255)); jTextCodigo.setDisabledTextColor(new java.awt.Color(255, 255, 255)); jTextCodigo.setSelectionColor(new java.awt.Color(255, 255, 255)); jTextCodigo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextCodigoActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jTextCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTextCodigo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Pesquisa", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N jTextFieldPesquisa.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextFieldPesquisaActionPerformed(evt); } }); jLabel14.setText("Pesquisa "); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { "Nome", "Morada", "NºContribuinte", "Localidade", "Codigo Postal", "Telémovel", "Telefone", "Tipo de Contrato", "Data de Instalação", "Data de Adesão", "Periodo de Fidelização", "Operadora" } ) { boolean[] canEdit = new boolean [] { false, false, false, false, false, false, false, false, false, false, false, false }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addComponent(jLabel14) .addGap(18, 18, 18) .addComponent(jTextFieldPesquisa)) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 815, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextFieldPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel14)) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addGap(24, 24, 24) .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, 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) .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton3) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(77, 77, 77) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(19, 19, 19) .addComponent(jLabel6) .addGap(23, 23, 23)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(12, 12, 12)) .addGroup(layout.createSequentialGroup() .addGap(94, 94, 94) .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 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) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton8) .addComponent(jButton3))) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton6) .addComponent(jButton5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton4) .addComponent(jButton7))) .addGroup(layout.createSequentialGroup() .addGap(92, 92, 92) .addComponent(jButton9))) .addGap(66, 66, 66)) ); jPanel2.getAccessibleContext().setAccessibleName(""); jPanel5.getAccessibleContext().setAccessibleName("Pesquisa"); pack(); }// </editor-fold> private void jTextCodigoActionPerformed(java.awt.event.ActionEvent evt) { } private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { try { if (conecta.rs.isFirst()){ conecta.rs.last(); } else{ conecta.rs.previous(); } jTextCodigo.setText(String.valueOf(conecta.rs.getInt("cod_cliente"))); jTextNome.setText(conecta.rs.getString("nome_cliente")); jTextMorada.setText(conecta.rs.getString("morada_cliente")); jTextContribuinte.setText(conecta.rs.getString("contribuinte_cliente")); jTextTelefone.setText(conecta.rs.getString("telefone_cliente")); jTextdata_instalacao.setText(conecta.rs.getString("data_instalacao")); jTexttipo_contrato.setText(conecta.rs.getString("tipo_contrato")); jTextdata_adesao.setText(conecta.rs.getString("data_adesao")); jTextper_fidelizacao.setText(conecta.rs.getString("per_fidelizacao")); jTextoperadora.setText(conecta.rs.getString("operador")); jTextFieldLocalidade_cliente.setText(conecta.rs.getString("localidade_cliente")); jTextFieldCod_postal.setText(conecta.rs.getString("cod_postal")); jTextFieldTelemovel_cliente.setText(conecta.rs.getString("telemovel_cliente")); jTextFieldEmail.setText(conecta.rs.getString("email_cliente")); jTextFieldServico.setText(conecta.rs.getString("servico")); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Erro na pesquisa"); } // TODO add your handling code here: } private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) { try { if (conecta.rs.isLast()){ conecta.rs.first(); } else{ conecta.rs.next(); } jTextCodigo.setText(String.valueOf(conecta.rs.getInt("cod_cliente"))); jTextNome.setText(conecta.rs.getString("nome_cliente")); jTextMorada.setText(conecta.rs.getString("morada_cliente")); jTextContribuinte.setText(conecta.rs.getString("contribuinte_cliente")); jTextTelefone.setText(conecta.rs.getString("telefone_cliente")); jTextdata_instalacao.setText(conecta.rs.getString("data_instalacao")); jTexttipo_contrato.setText(conecta.rs.getString("tipo_contrato")); jTextdata_adesao.setText(conecta.rs.getString("data_adesao")); jTextper_fidelizacao.setText(conecta.rs.getString("per_fidelizacao")); jTextoperadora.setText(conecta.rs.getString("operador")); jTextFieldLocalidade_cliente.setText(conecta.rs.getString("localidade_cliente")); jTextFieldCod_postal.setText(conecta.rs.getString("cod_postal")); jTextFieldTelemovel_cliente.setText(conecta.rs.getString("telemovel_cliente")); jTextFieldEmail.setText(conecta.rs.getString("email_cliente")); jTextFieldServico.setText(conecta.rs.getString("servico")); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Erro na pesquisa"); } // TODO add your handling code here: } private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) { try { conecta.rs.last(); jTextCodigo.setText(String.valueOf(conecta.rs.getInt("cod_cliente"))); jTextNome.setText(conecta.rs.getString("nome_cliente")); jTextMorada.setText(conecta.rs.getString("morada_cliente")); jTextContribuinte.setText(conecta.rs.getString("contribuinte_cliente")); jTextTelefone.setText(conecta.rs.getString("telefone_cliente")); jTextdata_instalacao.setText(conecta.rs.getString("data_instalacao")); jTexttipo_contrato.setText(conecta.rs.getString("tipo_contrato")); jTextdata_adesao.setText(conecta.rs.getString("data_adesao")); jTextper_fidelizacao.setText(conecta.rs.getString("per_fidelizacao")); jTextoperadora.setText(conecta.rs.getString("operador")); jTextFieldLocalidade_cliente.setText(conecta.rs.getString("localidade_cliente")); jTextFieldCod_postal.setText(conecta.rs.getString("cod_postal")); jTextFieldTelemovel_cliente.setText(conecta.rs.getString("telemovel_cliente")); jTextFieldEmail.setText(conecta.rs.getString("email_cliente")); jTextFieldServico.setText(conecta.rs.getString("servico")); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Erro na pesquisa"); } // TODO add your handling code here: } private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { try{ conecta.rs.first(); jTextCodigo.setText(String.valueOf(conecta.rs.getInt("cod_cliente"))); jTextNome.setText(conecta.rs.getString("nome_cliente")); jTextMorada.setText(conecta.rs.getString("morada_cliente")); jTextContribuinte.setText(conecta.rs.getString("contribuinte_cliente")); jTextTelefone.setText(conecta.rs.getString("telefone_cliente")); jTextdata_instalacao.setText(conecta.rs.getString("data_instalacao")); jTexttipo_contrato.setText(conecta.rs.getString("tipo_contrato")); jTextdata_adesao.setText(conecta.rs.getString("data_adesao")); jTextper_fidelizacao.setText(conecta.rs.getString("per_fidelizacao")); jTextoperadora.setText(conecta.rs.getString("operador")); jTextFieldLocalidade_cliente.setText(conecta.rs.getString("localidade_cliente")); jTextFieldCod_postal.setText(conecta.rs.getString("cod_postal")); jTextFieldTelemovel_cliente.setText(conecta.rs.getString("telemovel_cliente")); jTextFieldEmail.setText(conecta.rs.getString("email_cliente")); jTextFieldServico.setText(conecta.rs.getString("servico")); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Erro na pesquisa"); } // TODO add your handling co// TODO add your handling code here: } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { jTextCodigo.setText(""); jTextNome.setText(""); jTextMorada.setText(""); jTextContribuinte.setText(""); jTextTelefone.setText(""); jTextdata_instalacao.setText(""); jTexttipo_contrato.setText(""); jTextdata_adesao.setText(""); jTextper_fidelizacao.setText(""); jTextoperadora.setText(""); jTextFieldLocalidade_cliente.setText(""); jTextFieldCod_postal.setText(""); jTextFieldTelemovel_cliente.setText(""); jTextFieldEmail.setText(""); jTextFieldServico.setText(""); } private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) { try{ PreparedStatement pst= conecta.conn.prepareStatement("insert into ibit (nome_cliente,morada_cliente,telefone_cliente,contribuinte_cliente,data_instalacao,tipo_contrato,data_adesao,per_fidelizacao,operador, localidade_cliente, cod_postal, telemovel_cliente, email_cliente, servico) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); pst.setString(1,jTextNome.getText()); pst.setString(2,jTextMorada.getText()); pst.setString(3,jTextTelefone.getText()); pst.setString(4,jTextContribuinte.getText()); pst.setString(5,jTextdata_instalacao.getText()); pst.setString(6,jTexttipo_contrato.getText()); pst.setString(7,jTextdata_adesao.getText()); pst.setString(8,jTextper_fidelizacao.getText()); pst.setString(9,jTextoperadora.getText()); pst.setString(10,jTextFieldLocalidade_cliente.getText()); pst.setString(11,jTextFieldCod_postal.getText()); pst.setString(12,jTextFieldTelemovel_cliente.getText()); pst.setString(13,jTextFieldEmail.getText()); pst.setString(14,jTextFieldServico.getText()); pst.executeUpdate(); JOptionPane.showMessageDialog(null, "Cliente "+jTextNome.getText()+" registado com sucesso! "); } catch (SQLException erro) { JOptionPane.showMessageDialog(rootPane, "Erro ao registar o cliente: "+jTextNome.getText()+".\nErro:"+erro); } carregatudo(); } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { try{ PreparedStatement pst = conecta.conn.prepareStatement("delete from ibit where cod_cliente = ?"); pst.setInt(1,Integer.parseInt(jTextCodigo.getText())); pst.execute(); JOptionPane.showMessageDialog(rootPane,"Eliminado com sucesso!"); }catch (SQLException erro) { JOptionPane.showMessageDialog(rootPane, "Erro ao eliminar\n ERRO:"+erro); } carregatudo(); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { try{ PreparedStatement pst = conecta.conn.prepareStatement("update ibit set nome_cliente=?, morada_cliente=?,telefone_cliente=?,contribuinte_cliente=?, data_instalacao=?, tipo_contrato=?, data_adesao=?, per_fidelizacao=?, operador=?, localidade_cliente=?, cod_postal=?, telemovel_cliente=?, email_cliente=?, servico=? where cod_cliente=?"); pst.setString(1,jTextNome.getText()); pst.setString(2,jTextMorada.getText()); pst.setString(3,jTextTelefone.getText()); pst.setString(4,jTextContribuinte.getText()); pst.setString(5,jTextdata_instalacao.getText()); pst.setString(6,jTexttipo_contrato.getText()); pst.setString(7,jTextdata_adesao.getText()); pst.setString(8,jTextper_fidelizacao.getText()); pst.setString(9,jTextoperadora.getText()); pst.setString(10,jTextFieldLocalidade_cliente.getText()); pst.setString(11,jTextFieldCod_postal.getText()); pst.setString(12,jTextFieldTelemovel_cliente.getText()); pst.setString(13,jTextFieldEmail.getText()); pst.setString(14,jTextFieldServico.getText()); pst.setInt(15,Integer.parseInt(jTextCodigo.getText())); pst.execute(); JOptionPane.showMessageDialog(rootPane,"Alterado com sucesso"); } catch (SQLException erro){ JOptionPane.showMessageDialog(rootPane,"Erro ao alterar\n ERRO:"+erro); } carregatudo(); // TODO add your handling code here: } private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); // TODO add your handling code here: } private void jTextTelefoneActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jTextMoradaActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jTextFieldLocalidade_clienteActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jTextFieldCod_postalActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jTextNomeActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jTextFieldPesquisaActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jTextFieldEmailActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jTextFieldServicoActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } /** * @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(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Menu.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 Menu().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JButton jButton8; private javax.swing.JButton jButton9; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; 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.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel5; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator2; private javax.swing.JTable jTable1; private javax.swing.JTextField jTextCodigo; private javax.swing.JTextField jTextContribuinte; private javax.swing.JTextField jTextField4; private javax.swing.JTextField jTextFieldCod_postal; private javax.swing.JTextField jTextFieldEmail; private javax.swing.JTextField jTextFieldLocalidade_cliente; private javax.swing.JTextField jTextFieldPesquisa; private javax.swing.JTextField jTextFieldServico; private javax.swing.JTextField jTextFieldTelemovel_cliente; private javax.swing.JTextField jTextMorada; private javax.swing.JTextField jTextNome; private javax.swing.JTextField jTextTelefone; private javax.swing.JTextField jTextdata_adesao; private javax.swing.JTextField jTextdata_instalacao; private javax.swing.JTextField jTextoperadora; private javax.swing.JTextField jTextper_fidelizacao; private javax.swing.JTextField jTexttipo_contrato; // End of variables declaration } Link to comment Share on other sites More sharing options...
M6 Posted February 7, 2017 at 03:51 PM Report Share #602386 Posted February 7, 2017 at 03:51 PM (edited) A tua questão é de SQL e não de Java. Para fazeres uma pesquisa por nome de cliente tens de fazer uma query com a clausula like, algo do tipo: select * from cliente where nome like '%nome%' Edited February 7, 2017 at 03:51 PM by M6 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
pedro_miguel26 Posted February 7, 2017 at 04:02 PM Author Report Share #602387 Posted February 7, 2017 at 04:02 PM Obrigado M6, sou mesmo novo nisto. Isso ate foi o que ja tentei mas acaba sempre por dar erro. Podias me indicar no codigo um exemplo e onde colocar? Desculpa se estou a pedir de mais mas estou mesmo a nora com isto Link to comment Share on other sites More sharing options...
M6 Posted February 7, 2017 at 06:36 PM Report Share #602394 Posted February 7, 2017 at 06:36 PM O código de exemplo é o que eu escrevi anteriormente, onde o colocares é que já tem a ver com a lógica do programa, mas se tiveres um "carreganomes" (identico ao "carregatudo" mas modificado para receber uma string que será o nome a pesquisar) podes usar o "carreganomes" quando queres filtrar ou o "carregatudo" quando queres carregar tudo. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
pedro_miguel26 Posted February 8, 2017 at 09:18 AM Author Report Share #602402 Posted February 8, 2017 at 09:18 AM Vou tentar então, muito obrigado pela ajuda Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now