/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package applets;
import javax.swing.JOptionPane;
/**
*
* @author Greenlamp
*/
public class AppletHolidaysPassword extends javax.swing.JApplet {
/**
* Initializes the applet AppletHolidaysPassword
*/
@Override
public void init() {
/* 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(AppletHolidaysPassword.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AppletHolidaysPassword.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AppletHolidaysPassword.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AppletHolidaysPassword.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the applet */
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
activer(false);
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void setNom(String nom){
Gnom.setText(nom);
}
public void activer(boolean value){
Gvalider.setEnabled(value);
Gannuler.setEnabled(value);
}
/**
* This method is called from within the init() method 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() {
Gannuler = new javax.swing.JButton();
Gvalider = new javax.swing.JButton();
Lpass = new javax.swing.JLabel();
Gpass = new javax.swing.JTextField();
Lnom = new javax.swing.JLabel();
Gnom = new javax.swing.JLabel();
Gannuler.setText("annuler");
Gannuler.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
GannulerActionPerformed(evt);
}
});
Gvalider.setText("valider");
Gvalider.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
GvaliderActionPerformed(evt);
}
});
Lpass.setText("Choisissez votre mot de passe: ");
Lnom.setText("Votre nom: ");
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()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Lnom)
.addComponent(Lpass))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(Gpass, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
.addComponent(Gnom, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addComponent(Gvalider)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(Gannuler)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Lnom)
.addComponent(Gnom))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Gpass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Lpass))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Gvalider)
.addComponent(Gannuler))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void GannulerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GannulerActionPerformed
Gnom.setText(null);
Gpass.setText(null);
AppletHolidaysLogin app = (AppletHolidaysLogin) getAppletContext().getApplet("AppletHolidaysLogin");
activer(false);
app.activer(true);
}//GEN-LAST:event_GannulerActionPerformed
private void GvaliderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GvaliderActionPerformed
String pass = Gpass.getText();
if(!Gnom.getText().isEmpty()){
if(verifPass(pass)){
AppletHolidaysLogin app = (AppletHolidaysLogin) getAppletContext().getApplet("AppletHolidaysLogin");
app.setPass(pass);
app.activer(true);
app.setRegister(true);
}
}else{
JOptionPane.showMessageDialog(this, "Veuillez d'abord obtenir un nom");
}
}//GEN-LAST:event_GvaliderActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton Gannuler;
private javax.swing.JLabel Gnom;
private javax.swing.JTextField Gpass;
private javax.swing.JButton Gvalider;
private javax.swing.JLabel Lnom;
private javax.swing.JLabel Lpass;
// End of variables declaration//GEN-END:variables
private boolean verifPass(String pass) {
if(pass.isEmpty()){
JOptionPane.showMessageDialog(this, "Veuillez fournir un password");
return false;
}
return true;
}
}