Etudes/BTS/Java/Premiere annee/simclavier/FenClavier.java

546 lines
20 KiB
Java
Raw Permalink Normal View History

2016-10-14 15:52:18 +00:00
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package simclavier;
/**
*
* @author therbron
*/
public class FenClavier extends javax.swing.JFrame {
/**
* Creates new form FenClavier
*/
String textDefaut = "Veuillez saisir votre code";
public FenClavier() {
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() {
textMess = new javax.swing.JTextField();
jPanel1 = new javax.swing.JPanel();
touche1 = new javax.swing.JButton();
touche2 = new javax.swing.JButton();
touche3 = new javax.swing.JButton();
touche4 = new javax.swing.JButton();
touche5 = new javax.swing.JButton();
touche6 = new javax.swing.JButton();
touche7 = new javax.swing.JButton();
touche8 = new javax.swing.JButton();
touche9 = new javax.swing.JButton();
toucheEtoile = new javax.swing.JButton();
touche0 = new javax.swing.JButton();
toucheDiese = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setName("clavier"); // NOI18N
setPreferredSize(new java.awt.Dimension(220, 250));
setResizable(false);
getContentPane().setLayout(null);
textMess.setEditable(false);
textMess.setBackground(new java.awt.Color(20, 255, 20));
textMess.setText(textDefaut);
getContentPane().add(textMess);
textMess.setBounds(10, 10, 190, 30);
jPanel1.setBackground(new java.awt.Color(0, 0, 0));
jPanel1.setMinimumSize(new java.awt.Dimension(120, 160));
jPanel1.setPreferredSize(new java.awt.Dimension(120, 160));
jPanel1.setLayout(new java.awt.GridLayout(4, 3));
touche1.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
touche1.setText("1");
touche1.setToolTipText("Appuyer");
touche1.setMaximumSize(new java.awt.Dimension(26, 26));
touche1.setMinimumSize(new java.awt.Dimension(26, 26));
touche1.setPreferredSize(new java.awt.Dimension(26, 26));
touche1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
touche1MouseClicked(evt);
}
});
jPanel1.add(touche1);
touche2.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
touche2.setText("2");
touche2.setToolTipText("Appuyer");
touche2.setMaximumSize(new java.awt.Dimension(26, 26));
touche2.setMinimumSize(new java.awt.Dimension(26, 26));
touche2.setPreferredSize(new java.awt.Dimension(26, 26));
touche2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
touche2MouseClicked(evt);
}
});
jPanel1.add(touche2);
touche3.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
touche3.setText("3");
touche3.setToolTipText("Appuyer");
touche3.setMaximumSize(new java.awt.Dimension(26, 26));
touche3.setMinimumSize(new java.awt.Dimension(26, 26));
touche3.setPreferredSize(new java.awt.Dimension(26, 26));
touche3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
touche3MouseClicked(evt);
}
});
jPanel1.add(touche3);
touche4.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
touche4.setText("4");
touche4.setToolTipText("Appuyer");
touche4.setMaximumSize(new java.awt.Dimension(26, 26));
touche4.setMinimumSize(new java.awt.Dimension(26, 26));
touche4.setPreferredSize(new java.awt.Dimension(26, 26));
touche4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
touche4MouseClicked(evt);
}
});
jPanel1.add(touche4);
touche5.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
touche5.setText("5");
touche5.setToolTipText("Appuyer");
touche5.setMaximumSize(new java.awt.Dimension(26, 26));
touche5.setMinimumSize(new java.awt.Dimension(26, 26));
touche5.setPreferredSize(new java.awt.Dimension(26, 26));
touche5.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
touche5MouseClicked(evt);
}
});
jPanel1.add(touche5);
touche6.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
touche6.setText("6");
touche6.setToolTipText("Appuyer");
touche6.setMaximumSize(new java.awt.Dimension(26, 26));
touche6.setMinimumSize(new java.awt.Dimension(26, 26));
touche6.setPreferredSize(new java.awt.Dimension(26, 26));
touche6.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
touche6MouseClicked(evt);
}
});
jPanel1.add(touche6);
touche7.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
touche7.setText("7");
touche7.setToolTipText("Appuyer");
touche7.setMaximumSize(new java.awt.Dimension(26, 26));
touche7.setMinimumSize(new java.awt.Dimension(26, 26));
touche7.setPreferredSize(new java.awt.Dimension(26, 26));
touche7.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
touche7MouseClicked(evt);
}
});
jPanel1.add(touche7);
touche8.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
touche8.setText("8");
touche8.setToolTipText("Appuyer");
touche8.setMaximumSize(new java.awt.Dimension(26, 26));
touche8.setMinimumSize(new java.awt.Dimension(26, 26));
touche8.setPreferredSize(new java.awt.Dimension(26, 26));
touche8.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
touche8MouseClicked(evt);
}
});
jPanel1.add(touche8);
touche9.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
touche9.setText("9");
touche9.setToolTipText("Appuyer");
touche9.setMaximumSize(new java.awt.Dimension(26, 26));
touche9.setMinimumSize(new java.awt.Dimension(26, 26));
touche9.setPreferredSize(new java.awt.Dimension(26, 26));
touche9.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
touche9MouseClicked(evt);
}
});
jPanel1.add(touche9);
toucheEtoile.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
toucheEtoile.setText("*");
toucheEtoile.setToolTipText("Appuyer");
toucheEtoile.setMaximumSize(new java.awt.Dimension(26, 26));
toucheEtoile.setMinimumSize(new java.awt.Dimension(26, 26));
toucheEtoile.setPreferredSize(new java.awt.Dimension(26, 26));
toucheEtoile.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
toucheEtoileMouseClicked(evt);
}
});
jPanel1.add(toucheEtoile);
touche0.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
touche0.setText("0");
touche0.setToolTipText("Appuyer");
touche0.setMaximumSize(new java.awt.Dimension(26, 26));
touche0.setMinimumSize(new java.awt.Dimension(26, 26));
touche0.setPreferredSize(new java.awt.Dimension(26, 26));
touche0.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
touche0MouseClicked(evt);
}
});
jPanel1.add(touche0);
toucheDiese.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
toucheDiese.setText("#");
toucheDiese.setToolTipText("Appuyer");
toucheDiese.setMaximumSize(new java.awt.Dimension(26, 26));
toucheDiese.setMinimumSize(new java.awt.Dimension(26, 26));
toucheDiese.setPreferredSize(new java.awt.Dimension(26, 26));
toucheDiese.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
toucheDieseMouseClicked(evt);
}
});
jPanel1.add(toucheDiese);
getContentPane().add(jPanel1);
jPanel1.setBounds(10, 40, 190, 160);
pack();
}// </editor-fold>//GEN-END:initComponents
private void touche1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_touche1MouseClicked
// TODO add your handling code here:
if(textMess.getText().equals(textDefaut))
{
textMess.setText(touche1.getText());
}
else
{
if(textMess.getText().length() < 8)
{
textMess.setText(textMess.getText() + touche1.getText());
}
}
if(textMess.getText().length() == 8)
{
if(textMess.getText().equals("12345678"))
{
textMess.setText("Code bon");
}
else
{
textMess.setText("Code mauvais");
}
}
}//GEN-LAST:event_touche1MouseClicked
private void touche2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_touche2MouseClicked
// TODO add your handling code here:
if(textMess.getText().equals(textDefaut))
{
textMess.setText(touche2.getText());
}
else
{
if(textMess.getText().length() < 8)
{
textMess.setText(textMess.getText() + touche2.getText());
}
}
if(textMess.getText().length() == 8)
{
if(textMess.getText().equals("12345678"))
{
textMess.setText("Code bon");
}
else
{
textMess.setText("Code mauvais");
}
}
}//GEN-LAST:event_touche2MouseClicked
private void touche3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_touche3MouseClicked
// TODO add your handling code here:
if(textMess.getText().equals(textDefaut))
{
textMess.setText(touche3.getText());
}
else
{
if(textMess.getText().length() < 8)
{
textMess.setText(textMess.getText() + touche3.getText());
}
}
if(textMess.getText().length() == 8)
{
if(textMess.getText().equals("12345678"))
{
textMess.setText("Code bon");
}
else
{
textMess.setText("Code mauvais");
}
}
}//GEN-LAST:event_touche3MouseClicked
private void touche4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_touche4MouseClicked
// TODO add your handling code here:
if(textMess.getText().equals(textDefaut))
{
textMess.setText(touche4.getText());
}
else
{
if(textMess.getText().length() < 8)
{
textMess.setText(textMess.getText() + touche4.getText());
}
}
if(textMess.getText().length() == 8)
{
if(textMess.getText().equals("12345678"))
{
textMess.setText("Code bon");
}
else
{
textMess.setText("Code mauvais");
}
}
}//GEN-LAST:event_touche4MouseClicked
private void touche5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_touche5MouseClicked
// TODO add your handling code here:
if(textMess.getText().equals(textDefaut))
{
textMess.setText(touche5.getText());
}
else
{
if(textMess.getText().length() < 8)
{
textMess.setText(textMess.getText() + touche5.getText());
}
}
if(textMess.getText().length() == 8)
{
if(textMess.getText().equals("12345678"))
{
textMess.setText("Code bon");
}
else
{
textMess.setText("Code mauvais");
}
}
}//GEN-LAST:event_touche5MouseClicked
private void touche6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_touche6MouseClicked
// TODO add your handling code here:
if(textMess.getText().equals(textDefaut))
{
textMess.setText(touche6.getText());
}
else
{
if(textMess.getText().length() < 8)
{
textMess.setText(textMess.getText() + touche6.getText());
}
}
if(textMess.getText().length() == 8)
{
if(textMess.getText().equals("12345678"))
{
textMess.setText("Code bon");
}
else
{
textMess.setText("Code mauvais");
}
}
}//GEN-LAST:event_touche6MouseClicked
private void touche7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_touche7MouseClicked
// TODO add your handling code here:
if(textMess.getText().equals(textDefaut))
{
textMess.setText(touche7.getText());
}
else
{
if(textMess.getText().length() < 8)
{
textMess.setText(textMess.getText() + touche7.getText());
}
}
if(textMess.getText().length() == 8)
{
if(textMess.getText().equals("12345678"))
{
textMess.setText("Code bon");
}
else
{
textMess.setText("Code mauvais");
}
}
}//GEN-LAST:event_touche7MouseClicked
private void touche8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_touche8MouseClicked
// TODO add your handling code here:
if(textMess.getText().equals(textDefaut))
{
textMess.setText(touche8.getText());
}
else
{
if(textMess.getText().length() < 8)
{
textMess.setText(textMess.getText() + touche8.getText());
}
}
if(textMess.getText().length() == 8)
{
if(textMess.getText().equals("12345678"))
{
textMess.setText("Code bon");
}
else
{
textMess.setText("Code mauvais");
}
}
}//GEN-LAST:event_touche8MouseClicked
private void touche9MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_touche9MouseClicked
// TODO add your handling code here:
if(textMess.getText().equals(textDefaut))
{
textMess.setText(touche9.getText());
}
else
{
if(textMess.getText().length() < 8)
{
textMess.setText(textMess.getText() + touche9.getText());
}
}
if(textMess.getText().length() == 8)
{
if(textMess.getText().equals("12345678"))
{
textMess.setText("Code bon");
}
else
{
textMess.setText("Code mauvais");
}
}
}//GEN-LAST:event_touche9MouseClicked
private void toucheEtoileMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toucheEtoileMouseClicked
// TODO add your handling code here:
textMess.setText(textDefaut);
}//GEN-LAST:event_toucheEtoileMouseClicked
private void touche0MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_touche0MouseClicked
// TODO add your handling code here:
if(textMess.getText().equals(textDefaut))
{
textMess.setText(touche0.getText());
}
else
{
if(textMess.getText().length() < 8)
{
textMess.setText(textMess.getText() + touche0.getText());
}
}
}//GEN-LAST:event_touche0MouseClicked
private void toucheDieseMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toucheDieseMouseClicked
// TODO add your handling code here:
}//GEN-LAST:event_toucheDieseMouseClicked
/**
* @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(FenClavier.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FenClavier.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FenClavier.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(FenClavier.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 FenClavier().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField textMess;
private javax.swing.JButton touche0;
private javax.swing.JButton touche1;
private javax.swing.JButton touche2;
private javax.swing.JButton touche3;
private javax.swing.JButton touche4;
private javax.swing.JButton touche5;
private javax.swing.JButton touche6;
private javax.swing.JButton touche7;
private javax.swing.JButton touche8;
private javax.swing.JButton touche9;
private javax.swing.JButton toucheDiese;
private javax.swing.JButton toucheEtoile;
// End of variables declaration//GEN-END:variables
}