/* * Copyright (C) 2015 Allsoft * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package br.com.allsoft.avros.interfaces; import br.com.allsoft.avros.dao.UsuarioDAO; import java.awt.Container; import java.awt.Dimension; import java.sql.SQLException; import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; /** * * @author Luana */ public class IfrmEditSenha extends javax.swing.JInternalFrame { /** * Creates new form ifrmSenha */ public IfrmEditSenha() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); pswSenha = new javax.swing.JPasswordField(); pswNova = new javax.swing.JPasswordField(); pswConf = new javax.swing.JPasswordField(); btnSalvar = new javax.swing.JButton(); lblLogo = new javax.swing.JLabel(); jLabel1.setText("jLabel1"); setClosable(true); setIconifiable(true); setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/allsoft/avros/img/Keychain.png"))); // NOI18N addInternalFrameListener(new javax.swing.event.InternalFrameListener() { public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) { formInternalFrameClosed(evt); } public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) { formInternalFrameOpened(evt); } }); jLabel2.setFont(ClsEstilo.tituloFonte); jLabel2.setForeground(ClsEstilo.tituloCor); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("Mudar senha"); jLabel3.setFont(ClsEstilo.labelFonte); jLabel3.setForeground(ClsEstilo.labelCor); jLabel3.setText("Senha antiga"); jLabel4.setFont(ClsEstilo.labelFonte); jLabel4.setForeground(ClsEstilo.labelCor); jLabel4.setText("Nova senha"); jLabel5.setFont(ClsEstilo.labelFonte); jLabel5.setForeground(ClsEstilo.labelCor); jLabel5.setText("Confirma senha"); pswSenha.setFont(ClsEstilo.textoInputFonte); pswSenha.setForeground(ClsEstilo.textoInputCor); pswNova.setFont(ClsEstilo.textoInputFonte); pswNova.setForeground(ClsEstilo.textoInputCor); pswConf.setFont(ClsEstilo.textoInputFonte); pswConf.setForeground(ClsEstilo.textoInputCor); btnSalvar.setFont(ClsEstilo.botaoFonte); btnSalvar.setForeground(ClsEstilo.botaoCor); btnSalvar.setText("Salvar"); btnSalvar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSalvarActionPerformed(evt); } }); lblLogo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/allsoft/avros/img/logopequeno.png"))); // NOI18N 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) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(btnSalvar) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(pswSenha) .addComponent(pswNova, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE) .addComponent(pswConf)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE) .addComponent(lblLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel2) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(30, 30, 30) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(pswSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(pswNova, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(pswConf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE) .addComponent(btnSalvar)) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lblLogo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened Container a = this.getContentPane(); a.setBackground(ClsEstilo.formbg); Dimension dim = this.getParent().getSize(); this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2 + 50); }//GEN-LAST:event_formInternalFrameOpened private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed char[] antiga = pswSenha.getPassword(); char[] nova = pswNova.getPassword(); char[] conf = pswConf.getPassword(); if((antiga.length > 0) && (nova.length > 0) && (conf.length > 0)){ if((Arrays.equals(nova, conf)) && (Arrays.equals(antiga, FrmLogin.usuario.getSenha()))){ try { UsuarioDAO.uusuarioSenha(pswNova.getPassword(), FrmLogin.usuario.getId()); } catch (SQLException ex) { Logger.getLogger(IfrmEditSenha.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(null, "As senhas digitadas não coincidem."); } } else { JOptionPane.showMessageDialog(null, "Preencha todos os campos."); } }//GEN-LAST:event_btnSalvarActionPerformed private void formInternalFrameClosed(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosed FrmPrincipal.bSenha = false; }//GEN-LAST:event_formInternalFrameClosed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnSalvar; 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 lblLogo; private javax.swing.JPasswordField pswConf; private javax.swing.JPasswordField pswNova; private javax.swing.JPasswordField pswSenha; // End of variables declaration//GEN-END:variables }