IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Java Discussion :

Clavier code bancaire


Sujet :

Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    376
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2007
    Messages : 376
    Par défaut Clavier code bancaire
    Bonjour,

    J'ai créé un clavier pour saisir un code bancaire, il y a quelques bug pour récupérer le code saisi je n'arrive pas à le corriger.
    Je voudrais avoir un champ ou l'on puisse voir des étoiles quand le code est en train d'être saisi (4 chiffres possibles).

    Pourriez-vous m'aider, merci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
     
    public class SaisieCode extends JFrame implements ActionListener{	
    	private static final long serialVersionUID = 1L;
     
    	JButton un;
    	JButton deux;
    	JButton trois;
    	JButton quatre;
    	JButton cinq;
    	JButton six;
    	JButton sept;
    	JButton huit;
    	JButton neuf;
    	JButton zero;
    	JButton corriger;
    	JButton valider;
    	String code = "";
    	String numero = "";
    	String fauxcode ="";
    	JLabel affichagecode;
    	String langue = ChoixLangue.langue;
    	String carburant = ChoixCarburant.carburant;
     
    	public SaisieCode(){
    		super();
    		build();
    	}
     
    	private void build(){
    		setSize(600,400);
    		setLocationRelativeTo(null);
    		setContentPane(buildContentPane());
    	}
     
    	private JPanel buildContentPane(){
    		JPanel panel = new JPanel();
    		panel.setLayout(new BorderLayout());
     
    		JPanel nord = new JPanel();
    		nord.setLayout(new GridLayout(1, 1));
    		panel.add(nord, BorderLayout.NORTH);		
     
    		JLabel logo = new JLabel(new ImageIcon("logo.jpg"));
    		logo.setHorizontalAlignment(SwingConstants.LEFT);
    		nord.add(logo, ("1, 1"));
     
    		JPanel milieu = new JPanel();
    		milieu.setLayout(new GridLayout(1, 2));
    		panel.add(milieu, BorderLayout.CENTER);
    		JLabel texte;
    		if (langue == "Anglais") {
    			texte = new JLabel("PLEASE WRITE YOUR CODE");
    		}else{
    			texte = new JLabel("VEUILLEZ SAISIR VOTRE CODE A L’ABRI DES REGARDS INDISCRETS");
    		}
    		texte.setFont(new Font(null, Font.BOLD, 25));
    		texte.setHorizontalAlignment(SwingConstants.CENTER);
    		milieu.add(texte, ("1, 1"));
     
    		affichagecode = new JLabel(fauxcode);
    		affichagecode.setFont(new Font(null, Font.BOLD, 25));
    		affichagecode.setForeground(Color.black);
    		affichagecode.setBackground(Color.white);
    		affichagecode.setHorizontalAlignment(SwingConstants.CENTER);
    		milieu.add(affichagecode, ("2, 1"));
     
    		JPanel clavier = new JPanel();
    		clavier.setLayout(new GridLayout(4, 3));
    		clavier.setBackground(Color.white);
    		milieu.add(clavier, ("3, 1"));
     
    		un = new JButton("1");
    		un.setFont(new Font(null, Font.BOLD, 25));
    		un.setHorizontalAlignment(SwingConstants.CENTER);
    		un.addActionListener(this);
    		clavier.add(un, ("1, 1"));
     
    		deux = new JButton("2");
    		deux.setFont(new Font(null, Font.BOLD, 25));
    		deux.setHorizontalAlignment(SwingConstants.CENTER);
    		deux.addActionListener(this);
    		clavier.add(deux, ("1, 2"));
     
    		trois = new JButton("3");
    		trois.setFont(new Font(null, Font.BOLD, 25));
    		trois.setHorizontalAlignment(SwingConstants.CENTER);
    		trois.addActionListener(this);
    		clavier.add(trois, ("1, 3"));
     
    		quatre = new JButton("4");
    		quatre.setFont(new Font(null, Font.BOLD, 25));
    		quatre.setHorizontalAlignment(SwingConstants.CENTER);
    		quatre.addActionListener(this);
    		clavier.add(quatre, ("2, 1"));
     
    		cinq = new JButton("5");
    		cinq.setFont(new Font(null, Font.BOLD, 25));
    		cinq.setHorizontalAlignment(SwingConstants.CENTER);
    		cinq.addActionListener(this);
    		clavier.add(cinq, ("2, 2"));
     
    		six = new JButton("6");
    		six.setFont(new Font(null, Font.BOLD, 25));
    		six.setHorizontalAlignment(SwingConstants.CENTER);
    		six.addActionListener(this);
    		clavier.add(six, ("2, 3"));
     
    		sept = new JButton("7");
    		sept.setFont(new Font(null, Font.BOLD, 25));
    		sept.setHorizontalAlignment(SwingConstants.CENTER);
    		sept.addActionListener(this);
    		clavier.add(sept, ("3, 1"));
     
    		huit = new JButton("8");
    		huit.setFont(new Font(null, Font.BOLD, 25));
    		huit.setHorizontalAlignment(SwingConstants.CENTER);
    		huit.addActionListener(this);
    		clavier.add(huit, ("3, 2"));
     
    		neuf = new JButton("9");
    		neuf.setFont(new Font(null, Font.BOLD, 25));
    		neuf.setHorizontalAlignment(SwingConstants.CENTER);
    		neuf.addActionListener(this);
    		clavier.add(neuf, ("3, 3"));
     
    		corriger = new JButton("C");
    		corriger.setFont(new Font(null, Font.BOLD, 25));
    		corriger.setForeground(new Color(211, 211, 211));
    		corriger.setBackground(Color.red);
    		corriger.setHorizontalAlignment(SwingConstants.CENTER);
    		corriger.addActionListener(this);
    		clavier.add(corriger, ("4, 1"));
     
    		zero = new JButton("0");
    		zero.setFont(new Font(null, Font.BOLD, 25));
    		zero.setHorizontalAlignment(SwingConstants.CENTER);
    		zero.addActionListener(this);
    		clavier.add(zero, ("4, 2"));
     
    		valider = new JButton("V");
    		valider.setFont(new Font(null, Font.BOLD, 25));
    		valider.setForeground(new Color(211, 211, 211));
    		valider.setBackground(new Color(34, 139, 34));
    		valider.setHorizontalAlignment(SwingConstants.CENTER);
    		valider.addActionListener(this);
    		clavier.add(valider, ("4, 3"));		
     
    		return panel;
    	}
     
    	public void actionPerformed(ActionEvent e){
    		if(e.getSource() == corriger){
    			System.out.println("Corriger code");
    			SaisieCode saisircode = new SaisieCode();
    			saisircode.setVisible(true);
    		}else if(e.getSource() == un || e.getSource() == deux || e.getSource() == trois || e.getSource() == quatre || e.getSource() == cinq || e.getSource() == six || e.getSource() == sept || e.getSource() == huit || e.getSource() == neuf || e.getSource() == zero){
    			if(e.getSource() == un){ numero = "1"; }
    			if(e.getSource() == deux){ numero = "2"; }
    			if(e.getSource() == trois){ numero = "3"; }
    			if(e.getSource() == quatre){ numero = "4"; }
    			if(e.getSource() == cinq){ numero = "5"; }
    			if(e.getSource() == six){ numero = "6"; }
    			if(e.getSource() == sept){ numero = "7"; }
    			if(e.getSource() == huit){ numero = "8"; }
    			if(e.getSource() == neuf){ numero = "9"; }
    			if(e.getSource() == zero){ numero = "0"; }
    			code = code + numero;
    			fauxcode = fauxcode + "*";
    			affichagecode.setText(fauxcode);
    			System.out.println(code);
    			System.out.println(fauxcode);
    		}else if(e.getSource() == valider){
    			if(code == 1111){
    				System.out.println("Code bon");
    				CodeAccepte codeok = new CodeAccepte();
    				codeok.setVisible(true);
    			}else{
    				System.out.println("Code faux");
    				CodeRefuse codefaux = new CodeRefuse();
    				codefaux.setVisible(true);
    			}
    		}
    	}
    }

  2. #2
    Expert confirmé
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Par défaut
    Bonjour, ce que tu cherches est le composant JPasswordField

  3. #3
    Nouveau membre du Club
    Inscrit en
    Février 2009
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Février 2009
    Messages : 7
    Par défaut
    slt je va programmer un clavier virtuel avec jbeans ewactment comme un clavier normal avec afficheur de msg écrit

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. convertir code clavier en caractère
    Par danyboy85 dans le forum Général JavaScript
    Réponses: 13
    Dernier message: 22/02/2006, 19h15
  2. [TP] Problème code touche clavier
    Par phildeb dans le forum Turbo Pascal
    Réponses: 10
    Dernier message: 02/12/2005, 22h44
  3. Codes claviers
    Par yoyo01 dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 30/11/2005, 21h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo