コード例 #1
0
ファイル: IFCliente.java プロジェクト: valdemirsm/projetos
 private void BTSalvarActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_BTSalvarActionPerformed
   if (CBEstado.getSelectedIndex() == -1) {
     JOptionPane.showMessageDialog(null, "Informe o estado!", "Alerta", JOptionPane.ERROR_MESSAGE);
     return;
   }
   if (TFcodCli.getText().isEmpty()) {
     SalvarCliente();
   } else {
     AlterarCliente();
   }
 } // GEN-LAST:event_BTSalvarActionPerformed
コード例 #2
0
ファイル: IFCliente.java プロジェクト: valdemirsm/projetos
  /**
   * 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">//GEN-BEGIN:initComponents
  private void initComponents() {

    datePickerFormatter1 = new org.jdesktop.swingx.calendar.DatePickerFormatter();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    jPanel3 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    TbTelefone = new javax.swing.JTable();
    jScrollPane2 = new javax.swing.JScrollPane();
    TAObs = new javax.swing.JTextArea();
    jLabel8 = new javax.swing.JLabel();
    jPanel5 = new javax.swing.JPanel();
    BTNovo = new javax.swing.JButton();
    BTSalvar = new javax.swing.JButton();
    BTExcluir = new javax.swing.JButton();
    TFcodCli = new javax.swing.JTextField();
    TFNome = new javax.swing.JTextField();
    TFRua = new javax.swing.JTextField();
    TFBairro = new javax.swing.JTextField();
    jPanel1 = new javax.swing.JPanel();
    CBRegiao = new javax.swing.JComboBox();
    jLabel12 = new javax.swing.JLabel();
    jLabel13 = new javax.swing.JLabel();
    TFVlrTaxaEntrega = new Componentes.DKJTFFloat();
    jLabel14 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    TFNumero = new Componentes.DKJTFInteger();
    jLabel15 = new javax.swing.JLabel();
    TFCep1 = new Componentes.DKJTFCep();
    TFCPF = new Componentes.DKJTFCpf();
    tfTelefone = new Componentes.DKJTFFone();
    TFCidade = new javax.swing.JTextField();
    jLabel9 = new javax.swing.JLabel();
    CBEstado = new javax.swing.JComboBox();
    jLabel10 = new javax.swing.JLabel();
    jPanel4 = new javax.swing.JPanel();
    FTFfiltro = new javax.swing.JPanel();
    jLabel11 = new javax.swing.JLabel();
    TFDESCGERAL = new javax.swing.JTextField();
    BT_FILTER = new javax.swing.JButton();
    jScrollPane3 = new javax.swing.JScrollPane();
    TbPadrao = new javax.swing.JTable();

    setClosable(true);
    setIconifiable(true);
    setTitle("Cadastro de cliente");
    setMinimumSize(new java.awt.Dimension(658, 427));
    setRequestFocusEnabled(false);

    jPanel3.setLayout(null);

    jLabel1.setText("Código");
    jPanel3.add(jLabel1);
    jLabel1.setBounds(10, 0, 50, 14);
    jPanel3.add(jLabel3);
    jLabel3.setBounds(6, 167, 0, 0);

    jLabel2.setText("Nome");
    jPanel3.add(jLabel2);
    jLabel2.setBounds(60, 0, 260, 14);

    jLabel4.setText("Rua");
    jPanel3.add(jLabel4);
    jLabel4.setBounds(420, 50, 70, 14);

    jLabel6.setText("Bairro");
    jPanel3.add(jLabel6);
    jLabel6.setBounds(220, 50, 70, 14);

    jLabel7.setText("Número");
    jPanel3.add(jLabel7);
    jLabel7.setBounds(540, 50, 50, 14);

    TbTelefone.setModel(
        new javax.swing.table.DefaultTableModel(
            new Object[][] {}, new String[] {"id_cliente", "Lista de Telefones"}) {

          Class[] types = new Class[] {java.lang.Integer.class, java.lang.String.class};
          boolean[] canEdit = new boolean[] {false, false};

          public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
          }

          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
          }
        });
    jScrollPane1.setViewportView(TbTelefone);
    TbTelefone.getColumnModel().getColumn(0).setMinWidth(0);
    TbTelefone.getColumnModel().getColumn(0).setPreferredWidth(0);
    TbTelefone.getColumnModel().getColumn(0).setMaxWidth(0);

    jPanel3.add(jScrollPane1);
    jScrollPane1.setBounds(340, 250, 290, 110);

    TAObs.setColumns(20);
    TAObs.setRows(5);
    TAObs.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyPressed(java.awt.event.KeyEvent evt) {
            TAObsKeyPressed(evt);
          }
        });
    jScrollPane2.setViewportView(TAObs);

    jPanel3.add(jScrollPane2);
    jScrollPane2.setBounds(10, 120, 620, 60);

    jLabel8.setText("Observação");
    jPanel3.add(jLabel8);
    jLabel8.setBounds(10, 100, 130, 14);

    jPanel5.setBorder(
        javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

    BTNovo.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Imagens/Clear-32.png"))); // NOI18N
    BTNovo.setText("Limpar"); // NOI18N
    BTNovo.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            BTNovoActionPerformed(evt);
          }
        });

    BTSalvar.setIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/Imagens/1287691458_thumb-up.png"))); // NOI18N
    BTSalvar.setText("Salvar"); // NOI18N
    BTSalvar.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            BTSalvarActionPerformed(evt);
          }
        });

    BTExcluir.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Imagens/delete_16.png"))); // NOI18N
    BTExcluir.setText("Excluir"); // NOI18N
    BTExcluir.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            BTExcluirActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
    jPanel5.setLayout(jPanel5Layout);
    jPanel5Layout.setHorizontalGroup(
        jPanel5Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel5Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(BTNovo)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        BTSalvar,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        90,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        BTExcluir,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        90,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(15, Short.MAX_VALUE)));
    jPanel5Layout.setVerticalGroup(
        jPanel5Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel5Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        jPanel5Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(
                                BTNovo,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                BTSalvar,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                BTExcluir,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addContainerGap(14, Short.MAX_VALUE)));

    jPanel3.add(jPanel5);
    jPanel5.setBounds(10, 290, 320, 70);

    TFcodCli.setBackground(new java.awt.Color(204, 204, 204));
    TFcodCli.setEditable(false);
    TFcodCli.setEnabled(false);
    TFcodCli.setFocusable(false);
    jPanel3.add(TFcodCli);
    TFcodCli.setBounds(10, 20, 44, 20);

    TFNome.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            TFNomeActionPerformed(evt);
          }
        });
    jPanel3.add(TFNome);
    TFNome.setBounds(60, 20, 350, 20);
    jPanel3.add(TFRua);
    TFRua.setBounds(420, 70, 110, 20);

    TFBairro.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            TFBairroActionPerformed(evt);
          }
        });
    jPanel3.add(TFBairro);
    TFBairro.setBounds(220, 70, 190, 20);

    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Entrega"));

    CBRegiao.addItemListener(
        new java.awt.event.ItemListener() {
          public void itemStateChanged(java.awt.event.ItemEvent evt) {
            CBRegiaoItemStateChanged(evt);
          }
        });

    jLabel12.setText("Taxa entrega");

    jLabel13.setText("Região/Taxa");

    TFVlrTaxaEntrega.setText("");

    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)
                            .addComponent(
                                jLabel13,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                115,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                CBRegiao,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                135,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(85, 85, 85)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12, 0, 1, Short.MAX_VALUE)
                            .addComponent(
                                TFVlrTaxaEntrega,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                63,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap()));
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel1Layout
                    .createSequentialGroup()
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(jLabel12))
                    .addGap(7, 7, 7)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                CBRegiao,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                TFVlrTaxaEntrega,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(22, Short.MAX_VALUE)));

    jPanel3.add(jPanel1);
    jPanel1.setBounds(10, 190, 320, 90);

    jLabel14.setText("Cep");
    jPanel3.add(jLabel14);
    jLabel14.setBounds(540, 0, 50, 14);

    jLabel5.setText("Telefone");
    jPanel3.add(jLabel5);
    jLabel5.setBounds(340, 200, 70, 14);

    jButton1.setBackground(new java.awt.Color(255, 0, 0));
    jButton1.setText("Excluir");
    jButton1.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
          }
        });
    jPanel3.add(jButton1);
    jButton1.setBounds(510, 220, 73, 23);

    jButton2.setBackground(new java.awt.Color(0, 153, 0));
    jButton2.setText("Lançar");
    jButton2.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
          }
        });
    jPanel3.add(jButton2);
    jButton2.setBounds(430, 220, 70, 23);

    TFNumero.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            TFNumeroActionPerformed(evt);
          }
        });
    jPanel3.add(TFNumero);
    TFNumero.setBounds(540, 70, 90, 20);

    jLabel15.setText("CPF");
    jPanel3.add(jLabel15);
    jLabel15.setBounds(420, 0, 50, 14);

    TFCep1.addFocusListener(
        new java.awt.event.FocusAdapter() {
          public void focusLost(java.awt.event.FocusEvent evt) {
            TFCep1FocusLost(evt);
          }
        });
    jPanel3.add(TFCep1);
    TFCep1.setBounds(540, 20, 90, 20);
    jPanel3.add(TFCPF);
    TFCPF.setBounds(420, 20, 110, 20);
    jPanel3.add(tfTelefone);
    tfTelefone.setBounds(340, 220, 80, 20);
    jPanel3.add(TFCidade);
    TFCidade.setBounds(10, 70, 120, 20);

    jLabel9.setText("Estado");
    jPanel3.add(jLabel9);
    jLabel9.setBounds(140, 50, 60, 14);

    CBEstado.setModel(
        new javax.swing.DefaultComboBoxModel(
            new String[] {
              "AC", "AL", "AP", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA",
              "PB", "PR", "PE", "PI", "RJ", "RN", "RS", "RO", "RR", "SC", "SP", "SE", "TO"
            }));
    CBEstado.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            CBEstadoActionPerformed(evt);
          }
        });
    jPanel3.add(CBEstado);
    CBEstado.setBounds(140, 70, 70, 20);

    jLabel10.setText("Cidade");
    jPanel3.add(jLabel10);
    jLabel10.setBounds(10, 50, 90, 14);

    jTabbedPane1.addTab("Cadastro", jPanel3);

    FTFfiltro.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    jLabel11.setText("Nome do cliente:"); // NOI18N

    TFDESCGERAL.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyReleased(java.awt.event.KeyEvent evt) {
            TFDESCGERALKeyReleased(evt);
          }
        });

    BT_FILTER.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Imagens/Clear-32.png"))); // NOI18N
    BT_FILTER.setText("Limpar"); // NOI18N
    BT_FILTER.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            BT_FILTERActionPerformed(evt);
          }
        });
    BT_FILTER.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyPressed(java.awt.event.KeyEvent evt) {
            BT_FILTERKeyPressed(evt);
          }
        });

    javax.swing.GroupLayout FTFfiltroLayout = new javax.swing.GroupLayout(FTFfiltro);
    FTFfiltro.setLayout(FTFfiltroLayout);
    FTFfiltroLayout.setHorizontalGroup(
        FTFfiltroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                FTFfiltroLayout.createSequentialGroup()
                    .addComponent(
                        jLabel11,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        100,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        TFDESCGERAL,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        252,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED, 119, Short.MAX_VALUE)
                    .addComponent(
                        BT_FILTER,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        148,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    FTFfiltroLayout.setVerticalGroup(
        FTFfiltroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                FTFfiltroLayout.createSequentialGroup()
                    .addGap(6, 6, 6)
                    .addGroup(
                        FTFfiltroLayout.createParallelGroup(
                                javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(
                                TFDESCGERAL,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                25,
                                javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addComponent(BT_FILTER));

    TbPadrao.setAutoCreateRowSorter(true);
    TbPadrao.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    TbPadrao.setModel(
        new javax.swing.table.DefaultTableModel(
            new Object[][] {
              {null, null, null, null, null},
              {null, null, null, null, null},
              {null, null, null, null, null},
              {null, null, null, null, null}
            },
            new String[] {"Código", "Nome", "Rua", "Numero", "Bairro"}) {
          Class[] types =
              new Class[] {
                java.lang.Integer.class,
                java.lang.String.class,
                java.lang.String.class,
                java.lang.Integer.class,
                java.lang.String.class
              };
          boolean[] canEdit = new boolean[] {false, false, false, false, false};

          public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
          }

          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
          }
        });
    TbPadrao.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            TbPadraoMouseClicked1(evt);
          }
        });
    TbPadrao.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyPressed(java.awt.event.KeyEvent evt) {
            TbPadraoKeyPressed1(evt);
          }
        });
    jScrollPane3.setViewportView(TbPadrao);

    javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(
        jPanel4Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                FTFfiltro,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                Short.MAX_VALUE)
            .addComponent(
                jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE));
    jPanel4Layout.setVerticalGroup(
        jPanel4Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel4Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        FTFfiltro,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)));

    jTabbedPane1.addTab("Pesquisa", jPanel4);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 642, Short.MAX_VALUE));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE));

    setBounds(100, 50, 658, 427);
  } // </editor-fold>//GEN-END:initComponents