Authentification

cs_esteller Messages postés 49 Date d'inscription mardi 8 septembre 2009 Statut Membre Dernière intervention 26 novembre 2012 - 4 oct. 2012 à 13:33
 MINDONGO - 8 oct. 2012 à 21:03
bjr. j'aimerai savoir Comment faire la comparaison du login et password saisi par l’utilisateur et login et password existant ma base de donnée

package locvehiculelsit;
import java.awt.*;
import java.lang.*;
import javax.swing.*;
/**
 *
 * @author ESTELLE
 */
public class Authe extends javax.swing.JDialog{
  /** Creates new form NewJFrame */
    public Authe() {
        initComponents();
        setLocationRelativeTo(null);
    }
    
    /** 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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
     private void initComponents() {

        cmdok = new javax.swing.JButton();
        cmdannuler = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtutilisateur = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtpassword = new javax.swing.JPasswordField();

        //setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("VEUILLEZ VOUS IDENTIFIER");
        setBackground(new java.awt.Color(204, 204, 204));

        cmdok.setFont(new java.awt.Font("Times New Roman", 3, 24));
        cmdok.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ok.png"))); // NOI18N
        cmdok.setText("  OK");
        cmdok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdokActionPerformed(evt);
            }
        });

        cmdannuler.setFont(new java.awt.Font("Times New Roman", 3, 18));
        cmdannuler.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/delete.png"))); // NOI18N
        cmdannuler.setText("  Annuler");
        cmdannuler.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdannulerActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18));
        jLabel1.setText("Utilisateur :");

        jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 18));
        jLabel2.setText("Mot de passe :");

        jLabel3.setBackground(new java.awt.Color(0, 51, 255));
        jLabel3.setFont(new java.awt.Font("Times New Roman", 3, 14));
        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/voiture.jpg"))); // NOI18N
        jLabel3.setText("     ");

        jLabel4.setFont(new java.awt.Font("Times New Roman", 3, 18));
        jLabel4.setText("Entrez votre login et votre mot de passe");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(125, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(cmdok))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtpassword)
                    .addComponent(txtutilisateur, javax.swing.GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)
                    .addComponent(cmdannuler))
                .addGap(210, 210, 210))
            .addGroup(layout.createSequentialGroup()
                .addGap(105, 105, 105)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(181, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(66, 66, 66)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 369, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(151, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtutilisateur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(9, 9, 9)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(31, 31, 31)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cmdannuler, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cmdok, javax.swing.GroupLayout.PREFERRED_SIZE, 35, Short.MAX_VALUE))
                .addContainerGap(27, Short.MAX_VALUE))
        );

        getAccessibleContext().setAccessibleName("         VEUILLEZ VOUS IDENTIFIER");
        getAccessibleContext().setAccessibleParent(cmdannuler);

        pack();
    }// </editor-fold>
     
     private JTextField txtutilisateur() {
if (txtutilisateur == null) {
txtutilisateur = new JTextField();
txtutilisateur.setBounds(new Rectangle(330,235,100,20));
}
return txtutilisateur;
}
     
     
     private JPasswordField txtpassword() {
if (txtpassword == null) {
txtpassword = new JPasswordField();
txtpassword.setBounds(new Rectangle(330,335,100,20));
txtpassword.setEchoChar('*');
}
return txtpassword;
}


    private void cmdokActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
if(txtutilisateur.getText().equals(new String("carfo")))// || txtLog.getText()=="ADMINISTRATEUR")
if(String.copyValueOf(txtpassword.getPassword()).equals(new String("carfo")))
{
                                                    setVisible(false);
                                                   new Menus().setVisible(true);
                                                    //new menu().show();
//Main.connecte=true;

}
else
JOptionPane.showMessageDialog(null, "Vérifier le mot de passe");
                                        else
                                             JOptionPane.showMessageDialog(null, "Vérifier le loging");
                                }


    private void cmdannulerActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        this.dispose();
    }
    
    /**
     * @param args the command line arguments
     */
    /*public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Authentificationb().setVisible(true);
            }
        });
    }*/
    
    // Variables declaration - do not modify
    private javax.swing.JButton cmdannuler;
    private javax.swing.JButton cmdok;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPasswordField txtpassword;
    private javax.swing.JTextField txtutilisateur;
    // End of variables declaration
    
}

1 réponse

Bjr, je ne suis pas fort en Java mais pui je savoir votre SGBD
0
Rejoignez-nous