Identificationd'un element java.awt .(suite)

Fermé
marty25 Messages postés 56 Date d'inscription mercredi 1 août 2001 Statut Membre Dernière intervention 18 octobre 2002 - 4 avril 2002 à 10:10
choubaka Messages postés 39378 Date d'inscription jeudi 4 avril 2002 Statut Modérateur Dernière intervention 13 mai 2024 - 4 avril 2002 à 10:55
Re,

voici le code de ma methode action():

public boolean action(Event evt, Object arg)
{
if(evt.target instanceof Choice)
{
try{

return handleChoix(arg);
}catch(Exception e){return false;}
}//end if
else if(evt.target instanceof Button)
{
try{
return handleButton();
}catch(Exception e){return false;}
}//end if
else {return false;}
}//end action

Voila voila :)
Re-merci :)
Marty(...)

1 réponse

choubaka Messages postés 39378 Date d'inscription jeudi 4 avril 2002 Statut Modérateur Dernière intervention 13 mai 2024 2 101
4 avril 2002 à 10:55
alors voilà une solution élégante

Button myButton1 = new Button();
myButton1.addActionListener((new ActionListener() {
public void actionPerformed(ActionEvent evt) {
methodForButton1();
}
}
);

Button myButton2 = new Button();
myButton1.addActionListener((new ActionListener() {
public void actionPerformed(ActionEvent evt) {
methodForButton2();
}
}
);

private boolean methodForButton1(){

return le boolean resultat sur l'action du Button 1;

}

private boolean methodForButton2(){

return le boolean resultat sur l'action du Button 2;


}

ça devrait marcher

" Jusqu'où s'arrêteront-t'ils?"
0