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
| public class Authentification extends JFrame implements ActionListener {
protected TextField loginText = new TextField();
protected TextField mdpText = new TextField();
protected JLabel loginLabel = new JLabel("Login");
protected JLabel mdpLabel = new JLabel("Mot de passe");
protected JButton valider = new JButton("Valider");
protected JButton annuler = new JButton("Annuler");
protected JPanel panelBouton = new JPanel(new FlowLayout());
protected JPanel panelLogin = new JPanel(new GridLayout(1,2));
protected JPanel panelMdp = new JPanel(new GridLayout(1,2));
public Authentification(){
valider.addActionListener(this);
panelBouton.add(valider);
annuler.addActionListener(this);
panelBouton.add(annuler);
panelLogin.add(loginLabel);
panelLogin.add(loginText);
panelMdp.add(mdpLabel);
panelMdp.add(mdpText);
this.add(panelBouton,BorderLayout.SOUTH);
this.add(panelLogin,BorderLayout.NORTH);
this.add(panelMdp,BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
if(source==valider){
}else if(source==annuler){
System.out.println("test");
mdpText.setText("");
loginText.setText("");
}
}
} |