probléme en programme fenetre avec swing
salut,j'ai un probléme lors de l'éxecution du programme d'une simple fenetre avec un button
Code:
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
|
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
public class Form3 extends JFrame {
private static final long serialVersionUID = 42L;
JButton btnTest=null;
Container conteneur=null;
public Form3() {
this.setTitle("GRUNGY WITH JIHAD");
this.setSize(new Dimension(300,300));
WindowAdapter win= new WindowAdapter(){
public void windowClosing(WindowEvent e){System.exit(0);}
};
this.addWindowListener(win);
conteneur=this.getContentPane();
conteneur.setLayout(new FlowLayout());
btnTest=new JButton();
btnTest.setText("Click ici salopar");
conteneur.add(btnTest);
btnTest.setBounds(10,20,100,20);
btnTest.addActionListener(new ActionListener()
{
public void actionperformed(ActionEvent evt){
btnTest_clic(evt);
}
}
);
}
public void btnTest_clic(ActionEvent evt){
System.out.println("clic sur boutton ");
}
public static void main(String[] args){
new Form3().setVisible(true);
}
} |
le probléme reside au niveau de:
Code:
btnTest.addActionListener(new ActionListener()
et il m'affiche comme erreur:
Code:
1 2
|
the type new ActionListener(){} must implement the inherited abstract methode ActionListener.actionperformed(ActionEvent evt) |
à votre avis il me faut quoi faire dans ce truc la,SVP