Erreur dans la méthode actiobperformed

Résolu/Fermé
zohirdamene - 28 mai 2014 à 16:50
zohirdamene Messages postés 3 Date d'inscription lundi 5 mai 2014 Statut Membre Dernière intervention 1 juin 2014 - 28 mai 2014 à 23:08
salut
je suis entrain de realiser une application avec java eclips et la je suis bloqué
le problème ce que je veux ajouter un bouton parcourir dans l'interface et quand je veux associer l'action a executé pour le bouton parcourir mais quand je clique sur le bouton une erreur et affiché
j'ai bien implimenté l'interface action lestener
et aussi la méthode action perform
voila le code

package Interface;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import java.awt.event.*;

;


public class Fenetre extends JFrame implements ActionListener {


private JTextField nom ,id,chercher;
private JLabel nomLabel , idLabel,texte,idchercher;
private JPanel p,p1;
private JButton b1,parcourir;

@SuppressWarnings("static-access")
public Fenetre(){
{

int wd = 500; // largeur du fenetre
int ht = 580; // hauteur de la fenetre

int width=(Toolkit.getDefaultToolkit().getScreenSize().width-wd)/2;
int height=(Toolkit.getDefaultToolkit().getScreenSize().height-ht)/2;

// positioner la fenetre
this.setBounds(width, height, wd, ht);
this.setLayout(null);
this.setResizable(false);
// utiliser le style windows
try {
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName());
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
}
catch (Exception e) {
}





p= new JPanel();
p.setLayout(null);
p.setBackground(Color.white);
// p.setBounds(0,0,800,550);
p1= new JPanel();
p1.setLayout(null);
p1.setBackground(Color.white);
p1.setBorder(BorderFactory.createTitledBorder("les image de la signature"));
p1.setBounds(20,200,470,170);


nom = new JTextField();
nom.setPreferredSize(new Dimension(0, 25));
nom.setBounds(200, 50, 200, 20);

id=new JTextField();
id.setPreferredSize(new Dimension(0, 25));
id.setBounds(200,100,200,20);


texte =new JLabel("nouvel utilisateur :");
texte.setBounds(50, 20, 300, 20);

nomLabel = new JLabel(" nom :");
nomLabel.setBounds(150, 50, 200, 20);

idLabel =new JLabel("ID :");
idLabel.setBounds(150, 100, 200, 20);

b1=new JButton("valider");
b1.setBounds(390,518,100,30);

parcourir= new JButton("parcourir");
parcourir.setBounds(310, 50, 100, 20);
parcourir.addActionListener(this);

chercher=new JTextField();
chercher.setPreferredSize(new Dimension(0, 25));
chercher.setBounds(10, 50, 300, 20);

idchercher=new JLabel("importer votre signature");
idchercher.setBounds(10, 20, 300, 20);

p.setBorder(BorderFactory.createTitledBorder("identification"));
p.setBounds(20, 20, 470, 140);

p.add(nomLabel);
p.add(nom);
p.add(idLabel);
p.add(id);
p.add(texte);


p1.add(parcourir);
p1.add(chercher);
p1.add(idchercher);

//p1.add(b1);

Container c= this.getContentPane();


c.add(p);
c.add(p1);
c.add(b1);

this.setTitle("nouvel urilisateur ");


this.setVisible(true);

this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);}


}
@SuppressWarnings("static-access")
public void ActionPerformed (ActionEvent e){
if (e.getSource() == parcourir) System.out.println("choisir un fichier");

}




}

et voila l'erreur
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
The type Fenetre must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)

at nouveau_utilisature.Fenetre.actionPerformed(Fenetre.java:19)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
merci de m'aider svp

2 réponses

KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 3 015
28 mai 2014 à 19:08
Bonjour,

Il faut absolument respecter le nom de tes méthodes !

Ce n'est pas
actiobperformed
comme dans ton titre, ni
ActionPerformed
comme dans ton code, mais
actionPerformed
comme indiqué dans la trace d'erreur.

Remarque : si tu as cette trace d'erreur c'est aussi parce que tu as essayé d'exécuter un programme qui n'avait pas compilé d'abord ! Il aurait d'abord fallu corriger les erreurs de compilation...
1
zohirdamene Messages postés 3 Date d'inscription lundi 5 mai 2014 Statut Membre Dernière intervention 1 juin 2014
28 mai 2014 à 23:08
ah oui ta raison j'ai pas fais attention
merci pour votre réponse
0